Some improvements

This commit is contained in:
cutefishd 2021-03-29 22:53:21 +08:00
parent c3d7c6eedf
commit d6da7fe02c
10 changed files with 67 additions and 36 deletions

View file

@ -44,6 +44,7 @@ FolderModel::FolderModel(QObject *parent)
, m_sortDesc(false)
, m_sortDirsFirst(true)
, m_complete(false)
, m_isDesktop(false)
, m_actionCollection(this)
, m_dragInProgress(false)
, m_viewAdapter(nullptr)
@ -642,10 +643,11 @@ void FolderModel::openSelected()
return;
const QList<QUrl> urls = selectedUrls();
if (urls.size() == 1 && KFileItem(urls.first()).isDir()) {
setUrl(urls.first().toLocalFile());
return;
if (!m_isDesktop) {
if (urls.size() == 1 && KFileItem(urls.first()).isDir()) {
setUrl(urls.first().toLocalFile());
return;
}
}
for (const QUrl &url : urls) {
@ -934,6 +936,20 @@ bool FolderModel::isSupportThumbnails(const QString &mimeType) const
return false;
}
bool FolderModel::isDesktop() const
{
return m_isDesktop;
}
void FolderModel::setIsDesktop(bool isDesktop)
{
if (m_isDesktop == isDesktop)
return;
m_isDesktop = isDesktop;
emit isDesktopChanged();
}
void FolderModel::invalidateIfComplete()
{
if (!m_complete)

View file

@ -26,6 +26,7 @@ class FolderModel : public QSortFilterProxyModel, public QQmlParserStatus
Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged)
Q_PROPERTY(QObject *viewAdapter READ viewAdapter WRITE setViewAdapter NOTIFY viewAdapterChanged)
Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
Q_PROPERTY(bool isDesktop READ isDesktop WRITE setIsDesktop NOTIFY isDesktopChanged)
public:
enum DataRole {
@ -147,6 +148,9 @@ public:
Q_INVOKABLE void openPropertiesDialog();
Q_INVOKABLE void openInTerminal();
bool isDesktop() const;
void setIsDesktop(bool isDesktop);
signals:
void urlChanged();
void resolvedUrlChanged();
@ -158,6 +162,7 @@ signals:
void draggingChanged();
void viewAdapterChanged();
void statusTextChanged();
void isDesktopChanged();
private slots:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
@ -186,6 +191,7 @@ private:
bool m_sortDirsFirst;
bool m_complete;
bool m_isDesktop;
KActionCollection m_actionCollection;
QHash<int, DragImage *> m_dragImages;

View file

@ -73,3 +73,13 @@ QString PlacesItem::path() const
{
return m_url.toString(QUrl::PreferLocalFile);
}
QString PlacesItem::udi() const
{
return m_udi;
}
void PlacesItem::setUdi(const QString &udi)
{
m_udi = udi;
}

View file

@ -46,10 +46,14 @@ public:
QString path() const;
QString udi() const;
void setUdi(const QString &udi);
private:
QString m_displayName;
QString m_iconName;
QString m_iconPath;
QString m_udi;
QUrl m_url;
};

View file

@ -14,6 +14,10 @@ Item {
id: settings
}
GlobalSettings {
id: globalSettings
}
Loader {
id: backgroundLoader
anchors.fill: parent
@ -58,11 +62,12 @@ Item {
FolderGridView {
anchors.fill: parent
cellHeight: 128
cellWidth: 128
cellHeight: globalSettings.desktopIconSize
cellWidth: globalSettings.desktopIconSize
model: FolderModel {
id: folderModel
url: desktopPath()
isDesktop: true
}
leftMargin: desktopView.screenAvailableRect ? desktopView.screenAvailableRect.x : 0

View file

@ -27,7 +27,7 @@ Item {
Item {
id: _iconItem
Layout.preferredHeight: parent.height * 0.7
Layout.preferredHeight: parent.height * 0.6
Layout.fillWidth: true
Image {
@ -46,7 +46,7 @@ Item {
anchors.leftMargin: Meui.Units.smallSpacing
anchors.rightMargin: Meui.Units.smallSpacing
fillMode: Image.PreserveAspectCrop
fillMode: Image.PreserveAspectFit
visible: status === Image.Ready
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
@ -75,27 +75,27 @@ Item {
Item {
Layout.fillHeight: true
Layout.preferredHeight: Math.min(_label.implicitHeight, height)
Layout.fillWidth: true
Layout.preferredHeight: Math.min(_label.implicitHeight, height)
Rectangle {
width: Math.min(_label.implicitWidth + Meui.Units.smallSpacing, parent.width)
height: Math.min(_label.implicitHeight + Meui.Units.smallSpacing, parent.height)
anchors.centerIn: parent
width: Math.min(_label.implicitWidth + Meui.Units.largeSpacing, parent.width)
height: Math.min(_label.implicitHeight + Meui.Units.largeSpacing, parent.height)
color: selected ? Meui.Theme.highlightColor : "transparent"
radius: Meui.Theme.smallRadius
}
Label {
id: _label
anchors.fill: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
anchors.fill: parent
anchors.margins: 0
elide: Qt.ElideRight
wrapMode: Text.Wrap
color: selected ? Meui.Theme.highlightedTextColor : Meui.Theme.textColor
text: model.fileName
color: selected ? Meui.Theme.highlightedTextColor : Meui.Theme.textColor
}
}
}

View file

@ -28,10 +28,10 @@ GridView {
property Item editor: null
property int anchorIndex: 0
property var itemSize: 96 + Meui.Units.fontMetrics.height
property var itemSize: settings.gridIconSize
property var itemWidth: itemSize + Meui.Units.smallSpacing
property var itemHeight: itemSize + Meui.Units.largeSpacing
property var itemWidth: itemSize + Meui.Units.largeSpacing
property var itemHeight: itemSize + Meui.Units.fontMetrics.height * 2
property variant cachedRectangleSelection: null
@ -42,9 +42,6 @@ GridView {
signal keyPress(var event)
leftMargin: Meui.Units.smallSpacing
rightMargin: Meui.Units.smallSpacing
highlightMoveDuration: 0
keyNavigationEnabled : true
keyNavigationWraps : true

View file

@ -12,7 +12,7 @@ Item {
property alias currentUrl: folderModel.url
property Item currentView: _viewLoader.item
property int statusBarHeight: 30 + Meui.Units.smallSpacing
property int statusBarHeight: 30
signal requestPathEditor()
@ -83,7 +83,7 @@ Item {
anchors.fill: parent
anchors.leftMargin: Meui.Units.largeSpacing
anchors.rightMargin: Meui.Units.largeSpacing
anchors.bottomMargin: Meui.Units.smallSpacing
anchors.bottomMargin: 1
Label {
text: folderModel.statusText
@ -110,6 +110,11 @@ Item {
model: folderModel
delegate: FolderGridItem {}
leftMargin: Meui.Units.largeSpacing
rightMargin: Meui.Units.largeSpacing
topMargin: Meui.Units.smallSpacing
bottomMargin: Meui.Units.smallSpacing
onCountChanged: {
_fileTips.visible = count === 0
}

View file

@ -9,4 +9,6 @@ Settings {
property int desktopIconSize: 128
property int maximumIconSize: 256
property int minimumIconSize: 128
property int gridIconSize: 128
}

View file

@ -78,20 +78,6 @@ Meui.Window {
settings.viewMethod = 1
}
}
// IconButton {
// Layout.fillHeight: true
// implicitWidth: height
// source: Meui.Theme.darkMode ? "qrc:/images/dark/grid.svg" : "qrc:/images/light/grid.svg"
// onClicked: settings.viewMethod = 1
// }
// IconButton {
// Layout.fillHeight: true
// implicitWidth: height
// source: Meui.Theme.darkMode ? "qrc:/images/dark/list.svg" : "qrc:/images/light/list.svg"
// onClicked: settings.viewMethod = 0
// }
}
}