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 
31 namespace Fm {
32  class CachedFolderModel;
33  class ProxyFolderModel;
34  class FolderViewListView;
35 }
36 
37 namespace PCManFM {
38 
39 class DesktopItemDelegate;
40 class Settings;
41 
42 class DesktopWindow : public View {
43 Q_OBJECT
44 public:
45  friend class Application;
46 
47  enum WallpaperMode {
48  WallpaperNone,
49  WallpaperStretch,
50  WallpaperFit,
51  WallpaperCenter,
52  WallpaperTile
53  };
54 
55  explicit DesktopWindow(int screenNum);
56  virtual ~DesktopWindow();
57 
58  void setForeground(const QColor& color);
59  void setShadow(const QColor& color);
60  void setBackground(const QColor& color);
61  void setDesktopFolder();
62  void setWallpaperFile(QString filename);
63  void setWallpaperMode(WallpaperMode mode = WallpaperStretch);
64 
65  // void setWallpaperAlpha(qreal alpha);
66  void updateWallpaper();
67  void updateFromSettings(Settings& settings);
68 
69  void xcbEvent(xcb_generic_event_t* generic_event);
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 
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 onIndexesMoved(const QModelIndexList& indexes);
103 
104  void relayoutItems();
105  void onStickToCurrentPos(bool toggled);
106 
107  // void updateWorkArea();
108 
109  // file operations
110  void onCutActivated();
111  void onCopyActivated();
112  void onPasteActivated();
113  void onRenameActivated();
114  void onDeleteActivated();
115  void onFilePropertiesActivated();
116 
117 private:
118  Fm::ProxyFolderModel* proxyModel_;
119  Fm::CachedFolderModel* model_;
120  FmFolder* folder_;
121  Fm::FolderViewListView* listView_;
122 
123  QColor fgColor_;
124  QColor bgColor_;
125  QColor shadowColor_;
126  QString wallpaperFile_;
127  WallpaperMode wallpaperMode_;
128  QPixmap wallpaperPixmap_;
129  DesktopItemDelegate* delegate_;
130  Launcher fileLauncher_;
131  bool showWmMenu_;
132 
133  int screenNum_;
134  QHash<QByteArray, QPoint> customItemPos_;
135  QTimer* relayoutTimer_;
136 };
137 
138 }
139 
140 #endif // PCMANFM_DESKTOPWINDOW_H
Definition: appchoosercombobox.cpp:26
Definition: application.h:52
Definition: foldermenu.h:35
Definition: settings.h:33
Definition: filemenu.h:37
Definition: view.h:35
Definition: desktopitemdelegate.h:33
Definition: proxyfoldermodel.h:43
Definition: application.h:38
Definition: cachedfoldermodel.h:29
Definition: launcher.h:30
Definition: desktopwindow.h:42