PCManFM-Qt
desktopwindow.h
1 /*
2 
3  Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 
21 #ifndef PCMANFM_DESKTOPWINDOW_H
22 #define PCMANFM_DESKTOPWINDOW_H
23 
24 #include "view.h"
25 #include "launcher.h"
26 #include <QHash>
27 #include <QPoint>
28 #include <QByteArray>
29 #include <xcb/xcb.h>
30 #include <libfm-qt/folder.h>
31 
32 namespace Fm {
33  class CachedFolderModel;
34  class ProxyFolderModel;
35  class FolderViewListView;
36 }
37 
38 namespace PCManFM {
39 
40 class DesktopItemDelegate;
41 class Settings;
42 
43 class DesktopWindow : public View {
44 Q_OBJECT
45 public:
46  friend class Application;
47 
48  enum WallpaperMode {
49  WallpaperNone,
50  WallpaperStretch,
51  WallpaperFit,
52  WallpaperCenter,
53  WallpaperTile,
54  WallpaperZoom
55  };
56 
57  explicit DesktopWindow(int screenNum);
58  virtual ~DesktopWindow();
59 
60  void setForeground(const QColor& color);
61  void setShadow(const QColor& color);
62  void setBackground(const QColor& color);
63  void setDesktopFolder();
64  void setWallpaperFile(QString filename);
65  void setWallpaperMode(WallpaperMode mode = WallpaperStretch);
66 
67  // void setWallpaperAlpha(qreal alpha);
68  void updateWallpaper();
69  void updateFromSettings(Settings& settings);
70 
71  void queueRelayout(int delay = 0);
72 
73  int screenNum() const {
74  return screenNum_;
75  }
76 
77  void setScreenNum(int num);
78 
79 protected:
80  virtual void prepareFolderMenu(Fm::FolderMenu* menu);
81  virtual void prepareFileMenu(Fm::FileMenu* menu);
82  virtual void resizeEvent(QResizeEvent* event);
83  virtual void onFileClicked(int type, FmFileInfo* fileInfo);
84 
85  void loadItemPositions();
86  void saveItemPositions();
87 
88  QImage loadWallpaperFile(QSize requiredSize);
89 
90  virtual bool event(QEvent* event);
91  virtual bool eventFilter(QObject * watched, QEvent * event);
92 
93  virtual void childDropEvent(QDropEvent* e);
94  virtual void closeEvent(QCloseEvent *event);
95 
96 protected Q_SLOTS:
97  void onOpenDirRequested(FmPath* path, int target);
98  void onDesktopPreferences();
99 
100  void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
101  void onRowsInserted(const QModelIndex& parent, int start, int end);
102  void onLayoutChanged();
103  void onModelSortFilterChanged();
104  void onIndexesMoved(const QModelIndexList& indexes);
105  void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
106 
107  void relayoutItems();
108  void onStickToCurrentPos(bool toggled);
109 
110  // void updateWorkArea();
111 
112  // file operations
113  void onCutActivated();
114  void onCopyActivated();
115  void onPasteActivated();
116  void onRenameActivated();
117  void onDeleteActivated();
118  void onFilePropertiesActivated();
119 
120 private:
121  void removeBottomGap();
122 
123 private:
124  Fm::ProxyFolderModel* proxyModel_;
125  Fm::CachedFolderModel* model_;
126  Fm::Folder folder_;
127  Fm::FolderViewListView* listView_;
128 
129  QColor fgColor_;
130  QColor bgColor_;
131  QColor shadowColor_;
132  QString wallpaperFile_;
133  WallpaperMode wallpaperMode_;
134  QPixmap wallpaperPixmap_;
135  DesktopItemDelegate* delegate_;
136  Launcher fileLauncher_;
137  bool showWmMenu_;
138 
139  int screenNum_;
140  QHash<QByteArray, QPoint> customItemPos_;
141  QHash<QModelIndex, QString> displayNames_; // only for desktop entries and shortcuts
142  QTimer* relayoutTimer_;
143 };
144 
145 }
146 
147 #endif // PCMANFM_DESKTOPWINDOW_H
Definition: desktopwindow.h:32
Definition: application.h:53
Definition: settings.h:121
Definition: view.h:35
Definition: desktopitemdelegate.h:33
Definition: application.cpp:59
Definition: launcher.h:30
Definition: desktopwindow.h:43