Update icon size

This commit is contained in:
cutefishd 2021-05-06 11:24:12 +08:00
parent 4eb3b17f1e
commit 379d4b78bf
7 changed files with 14 additions and 8 deletions

1
.gitignore vendored
View file

@ -52,3 +52,4 @@ compile_commands.json
*creator.user* *creator.user*
build/* build/*
.vscode/

View file

@ -1,5 +0,0 @@
{
"files.associations": {
"*.moc": "cpp"
}
}

View file

@ -12,7 +12,7 @@ DockItem {
isActive: model.isActive isActive: model.isActive
popupText: model.visibleName popupText: model.visibleName
enableActivateDot: windowCount !== 0 enableActivateDot: windowCount !== 0
draggable: model.appId === "cutefish-launcher" ? false : true draggable: !model.fixed
dragItemIndex: index dragItemIndex: index
onXChanged: { onXChanged: {
@ -80,6 +80,9 @@ DockItem {
function updateGeometry() { function updateGeometry() {
if (model.fixed)
return
appModel.updateGeometries(model.appId, Qt.rect(appItem.mapToGlobal(0, 0).x, appModel.updateGeometries(model.appId, Qt.rect(appItem.mapToGlobal(0, 0).x,
appItem.mapToGlobal(0, 0).y, appItem.mapToGlobal(0, 0).y,
appItem.width, appItem.height)) appItem.width, appItem.height))

View file

@ -20,6 +20,7 @@ public:
int currentActive = 0; int currentActive = 0;
bool isActive = false; bool isActive = false;
bool isPinned = false; bool isPinned = false;
bool fixed = false;
bool operator==(ApplicationItem item) { bool operator==(ApplicationItem item) {
return item.id == this->id; return item.id == this->id;

View file

@ -53,6 +53,7 @@ QHash<int, QByteArray> ApplicationModel::roleNames() const
roles[WindowCountRole] = "windowCount"; roles[WindowCountRole] = "windowCount";
roles[IsPinnedRole] = "isPinned"; roles[IsPinnedRole] = "isPinned";
roles[DesktopFileRole] = "desktopFile"; roles[DesktopFileRole] = "desktopFile";
roles[FixedItemRole] = "fixed";
return roles; return roles;
} }
@ -78,6 +79,8 @@ QVariant ApplicationModel::data(const QModelIndex &index, int role) const
return item->isPinned; return item->isPinned;
case DesktopFileRole: case DesktopFileRole:
return item->desktopPath; return item->desktopPath;
case FixedItemRole:
return item->fixed;
default: default:
return QVariant(); return QVariant();
} }
@ -280,6 +283,7 @@ void ApplicationModel::initPinnedApplications()
item->exec = "cutefish-launcher"; item->exec = "cutefish-launcher";
item->iconName = "qrc:/svg/launcher.svg"; item->iconName = "qrc:/svg/launcher.svg";
item->visibleName = tr("Launcher"); item->visibleName = tr("Launcher");
item->fixed = true;
m_appItems.append(item); m_appItems.append(item);
// Pinned Apps // Pinned Apps

View file

@ -37,7 +37,8 @@ public:
ActiveRole, ActiveRole,
WindowCountRole, WindowCountRole,
IsPinnedRole, IsPinnedRole,
DesktopFileRole DesktopFileRole,
FixedItemRole
}; };
explicit ApplicationModel(QObject *parent = nullptr); explicit ApplicationModel(QObject *parent = nullptr);

View file

@ -91,7 +91,8 @@ QRect MainWindow::windowRect() const
: availableGeometry.height() - m_settings->edgeMargins();; : availableGeometry.height() - m_settings->edgeMargins();;
int appCount = m_appModel->rowCount(); int appCount = m_appModel->rowCount();
qreal iconSize = m_settings->iconSize() * qApp->devicePixelRatio(); int iconSize = m_settings->iconSize();
iconSize += iconSize * 0.1;
int length = appCount * iconSize; int length = appCount * iconSize;
if (length > maxLength) { if (length > maxLength) {