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