PCManFM-Qt
 All Classes
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  };
55 
56  explicit DesktopWindow(int screenNum);
57  virtual ~DesktopWindow();
58 
59  void setForeground(const QColor& color);
60  void setShadow(const QColor& color);
61  void setBackground(const QColor& color);
62  void setDesktopFolder();
63  void setWallpaperFile(QString filename);
64  void setWallpaperMode(WallpaperMode mode = WallpaperStretch);
65 
66  // void setWallpaperAlpha(qreal alpha);
67  void updateWallpaper();
68  void updateFromSettings(Settings& settings);
69 
70  void queueRelayout(int delay = 0);
71 
72  int screenNum() const {
73  return screenNum_;
74  }
75 
76  void setScreenNum(int num);
77 
78 protected:
79  virtual void prepareFolderMenu(Fm::FolderMenu* menu);
80  virtual void prepareFileMenu(Fm::FileMenu* menu);
81  virtual void resizeEvent(QResizeEvent* event);
82  virtual void onFileClicked(int type, FmFileInfo* fileInfo);
83 
84  void loadItemPositions();
85  void saveItemPositions();
86 
87  QImage loadWallpaperFile(QSize requiredSize);
88 
89  virtual bool event(QEvent* event);
90  virtual bool eventFilter(QObject * watched, QEvent * event);
91 
92  virtual void childDropEvent(QDropEvent* e);
93  virtual void closeEvent(QCloseEvent *event);
94 
95 protected Q_SLOTS:
96  void onOpenDirRequested(FmPath* path, int target);
97  void onDesktopPreferences();
98 
99  void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
100  void onRowsInserted(const QModelIndex& parent, int start, int end);
101  void onLayoutChanged();
102  void onModelSortFilterChanged();
103  void onIndexesMoved(const QModelIndexList& indexes);
104 
105  void relayoutItems();
106  void onStickToCurrentPos(bool toggled);
107 
108  // void updateWorkArea();
109 
110  // file operations
111  void onCutActivated();
112  void onCopyActivated();
113  void onPasteActivated();
114  void onRenameActivated();
115  void onDeleteActivated();
116  void onFilePropertiesActivated();
117 
118 private:
119  void removeBottomGap();
120 
121 private:
122  Fm::ProxyFolderModel* proxyModel_;
123  Fm::CachedFolderModel* model_;
124  Fm::Folder folder_;
125  Fm::FolderViewListView* listView_;
126 
127  QColor fgColor_;
128  QColor bgColor_;
129  QColor shadowColor_;
130  QString wallpaperFile_;
131  WallpaperMode wallpaperMode_;
132  QPixmap wallpaperPixmap_;
133  DesktopItemDelegate* delegate_;
134  Launcher fileLauncher_;
135  bool showWmMenu_;
136 
137  int screenNum_;
138  QHash<QByteArray, QPoint> customItemPos_;
139  QTimer* relayoutTimer_;
140 };
141 
142 }
143 
144 #endif // PCMANFM_DESKTOPWINDOW_H
Definition: application.h:52
Definition: settings.h:121
Definition: view.h:35
Definition: desktopitemdelegate.h:33
Definition: launcher.h:30
Definition: desktopwindow.h:43