PCManFM-Qt
 All Classes
settings.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_SETTINGS_H
22 #define PCMANFM_SETTINGS_H
23 
24 #include <QObject>
25 #include <libfm/fm.h>
26 #include "folderview.h"
27 #include "foldermodel.h"
28 #include "desktopwindow.h"
29 #include "thumbnailloader.h"
30 
31 namespace PCManFM {
32 
33 class Settings : public QObject {
34  Q_OBJECT
35 public:
36  Settings();
37  virtual ~Settings();
38 
39  bool load(QString profile = "default");
40  bool save(QString profile = QString());
41 
42  bool loadFile(QString filePath);
43  bool saveFile(QString filePath);
44 
45  QString profileDir(QString profile, bool useFallback = false);
46 
47  // setter/getter functions
48  QString profileName() const {
49  return profileName_;
50  }
51 
52  bool supportTrash() const {
53  return supportTrash_;
54  }
55 
56  QString fallbackIconThemeName() const {
57  return fallbackIconThemeName_;
58  }
59 
60  bool useFallbackIconTheme() const {
61  return useFallbackIconTheme_;
62  }
63 
64  void setFallbackIconThemeName(QString iconThemeName) {
65  fallbackIconThemeName_ = iconThemeName;
66  }
67 
68  int bookmarkOpenMethod() {
69  return bookmarkOpenMethod_;
70  }
71 
72  void setBookmarkOpenMethod(int bookmarkOpenMethod) {
73  bookmarkOpenMethod_ = bookmarkOpenMethod;
74  }
75 
76  QString suCommand() const {
77  return suCommand_;
78  }
79 
80  void setSuCommand(QString suCommand) {
81  suCommand_ = suCommand;
82  }
83 
84  QString terminal() {
85  return terminal_;
86  }
87  void setTerminal(QString terminalCommand);
88 
89  QString archiver() const {
90  return archiver_;
91  }
92 
93  void setArchiver(QString archiver) {
94  archiver_ = archiver;
95  // override libfm FmConfig
96  g_free(fm_config->archiver);
97  fm_config->archiver = g_strdup(archiver_.toLocal8Bit().constData());
98  }
99 
100  bool mountOnStartup() const {
101  return mountOnStartup_;
102  }
103 
104  void setMountOnStartup(bool mountOnStartup) {
105  mountOnStartup_ = mountOnStartup;
106  }
107 
108  bool mountRemovable() {
109  return mountRemovable_;
110  }
111 
112  void setMountRemovable(bool mountRemovable) {
113  mountRemovable_ = mountRemovable;
114  }
115 
116  bool autoRun() const {
117  return autoRun_;
118  }
119 
120  void setAutoRun(bool autoRun) {
121  autoRun_ = autoRun;
122  }
123 
124  bool closeOnUnmount() const {
125  return closeOnUnmount_;
126  }
127 
128  void setCloseOnUnmount(bool value) {
129  closeOnUnmount_ = value;
130  }
131 
132  DesktopWindow::WallpaperMode wallpaperMode() const {
133  return DesktopWindow::WallpaperMode(wallpaperMode_);
134  }
135 
136  void setWallpaperMode(int wallpaperMode) {
137  wallpaperMode_ = wallpaperMode;
138  }
139 
140  QString wallpaper() const {
141  return wallpaper_;
142  }
143 
144  void setWallpaper(QString wallpaper) {
145  wallpaper_ = wallpaper;
146  }
147 
148  const QColor& desktopBgColor() const {
149  return desktopBgColor_;
150  }
151 
152  void setDesktopBgColor(QColor desktopBgColor) {
153  desktopBgColor_ = desktopBgColor;
154  }
155 
156  const QColor& desktopFgColor() const {
157  return desktopFgColor_;
158  }
159 
160  void setDesktopFgColor(QColor desktopFgColor) {
161  desktopFgColor_ = desktopFgColor;
162  }
163 
164  const QColor& desktopShadowColor() const {
165  return desktopShadowColor_;
166  }
167 
168  void setDesktopShadowColor(QColor desktopShadowColor) {
169  desktopShadowColor_ = desktopShadowColor;
170  }
171 
172  QFont desktopFont() const {
173  return desktopFont_;
174  }
175 
176  void setDesktopFont(QFont font) {
177  desktopFont_ = font;
178  }
179 
180  bool showWmMenu() const {
181  return showWmMenu_;
182  }
183 
184  void setShowWmMenu(bool value) {
185  showWmMenu_ = value;
186  }
187 
188  bool desktopShowHidden() const {
189  return desktopShowHidden_;
190  }
191 
192  void setDesktopShowHidden(bool desktopShowHidden) {
193  desktopShowHidden_ = desktopShowHidden;
194  }
195 
196  Qt::SortOrder desktopSortOrder() const {
197  return desktopSortOrder_;
198  }
199 
200  void setDesktopSortOrder(Qt::SortOrder desktopSortOrder) {
201  desktopSortOrder_ = desktopSortOrder;
202  }
203 
204  Fm::FolderModel::ColumnId desktopSortColumn() const {
205  return desktopSortColumn_;
206  }
207 
208  void setDesktopSortColumn(Fm::FolderModel::ColumnId desktopSortColumn) {
209  desktopSortColumn_ = desktopSortColumn;
210  }
211 
212  bool alwaysShowTabs() const {
213  return alwaysShowTabs_;
214  }
215 
216  void setAlwaysShowTabs(bool alwaysShowTabs) {
217  alwaysShowTabs_ = alwaysShowTabs;
218  }
219 
220  bool showTabClose() const {
221  return showTabClose_;
222  }
223 
224  void setShowTabClose(bool showTabClose) {
225  showTabClose_ = showTabClose;
226  }
227 
228  bool rememberWindowSize() const {
229  return rememberWindowSize_;
230  }
231 
232  void setRememberWindowSize(bool rememberWindowSize) {
233  rememberWindowSize_ = rememberWindowSize;
234  }
235 
236  int windowWidth() const {
237  if(rememberWindowSize_)
238  return lastWindowWidth_;
239  else
240  return fixedWindowWidth_;
241  }
242 
243  int windowHeight() const {
244  if(rememberWindowSize_)
245  return lastWindowHeight_;
246  else
247  return fixedWindowHeight_;
248  }
249 
250  bool windowMaximized() const {
251  if(rememberWindowSize_)
252  return lastWindowMaximized_;
253  else
254  return false;
255  }
256 
257  int fixedWindowWidth() const {
258  return fixedWindowWidth_;
259  }
260 
261  void setFixedWindowWidth(int fixedWindowWidth) {
262  fixedWindowWidth_ = fixedWindowWidth;
263  }
264 
265  int fixedWindowHeight() const {
266  return fixedWindowHeight_;
267  }
268 
269  void setFixedWindowHeight(int fixedWindowHeight) {
270  fixedWindowHeight_ = fixedWindowHeight;
271  }
272 
273  void setLastWindowWidth(int lastWindowWidth) {
274  lastWindowWidth_ = lastWindowWidth;
275  }
276 
277  void setLastWindowHeight(int lastWindowHeight) {
278  lastWindowHeight_ = lastWindowHeight;
279  }
280 
281  void setLastWindowMaximized(bool lastWindowMaximized) {
282  lastWindowMaximized_ = lastWindowMaximized;
283  }
284 
285  int splitterPos() const {
286  return splitterPos_;
287  }
288 
289  void setSplitterPos(int splitterPos) {
290  splitterPos_ = splitterPos;
291  }
292 
293  int sidePaneMode() const {
294  return sidePaneMode_;
295  }
296 
297  void setSidePaneMode(int sidePaneMode) {
298  sidePaneMode_ = sidePaneMode;
299  }
300 
301  Fm::FolderView::ViewMode viewMode() const {
302  return viewMode_;
303  }
304 
305  void setViewMode(Fm::FolderView::ViewMode viewMode) {
306  viewMode_ = viewMode;
307  }
308 
309  bool showHidden() const {
310  return showHidden_;
311  }
312 
313  void setShowHidden(bool showHidden) {
314  showHidden_ = showHidden;
315  }
316 
317  Qt::SortOrder sortOrder() const {
318  return sortOrder_;
319  }
320 
321  void setSortOrder(Qt::SortOrder sortOrder) {
322  sortOrder_ = sortOrder;
323  }
324 
325  Fm::FolderModel::ColumnId sortColumn() const {
326  return sortColumn_;
327  }
328 
329  void setSortColumn(Fm::FolderModel::ColumnId sortColumn) {
330  sortColumn_ = sortColumn;
331  }
332 
333  // settings for use with libfm
334  bool singleClick() const {
335  return singleClick_;
336  }
337 
338  void setSingleClick(bool singleClick) {
339  singleClick_ = singleClick;
340  }
341 
342  int autoSelectionDelay() const {
343  return autoSelectionDelay_;
344  }
345 
346  void setAutoSelectionDelay(int value) {
347  autoSelectionDelay_ = value;
348  }
349 
350  bool useTrash() const {
351  if(!supportTrash_)
352  return false;
353  return useTrash_;
354  }
355 
356  void setUseTrash(bool useTrash) {
357  useTrash_ = useTrash;
358  }
359 
360  bool confirmDelete() const {
361  return confirmDelete_;
362  }
363 
364  void setConfirmDelete(bool confirmDelete) {
365  confirmDelete_ = confirmDelete;
366  }
367 
368  bool noUsbTrash() const {
369  return noUsbTrash_;
370  }
371 
372  void setNoUsbTrash(bool noUsbTrash) {
373  noUsbTrash_ = noUsbTrash;
374  }
375 
376  // bool thumbnailLocal_;
377  // bool thumbnailMax;
378 
379  int bigIconSize() const {
380  return bigIconSize_;
381  }
382 
383  void setBigIconSize(int bigIconSize) {
384  bigIconSize_ = bigIconSize;
385  }
386 
387  int smallIconSize() const {
388  return smallIconSize_;
389  }
390 
391  void setSmallIconSize(int smallIconSize) {
392  smallIconSize_ = smallIconSize;
393  }
394 
395  int sidePaneIconSize() const {
396  return sidePaneIconSize_;
397  }
398 
399  void setSidePaneIconSize(int sidePaneIconSize) {
400  sidePaneIconSize_ = sidePaneIconSize;
401  }
402 
403  int thumbnailIconSize() const {
404  return thumbnailIconSize_;
405  }
406 
407  bool showThumbnails() {
408  return showThumbnails_;
409  }
410 
411  void setShowThumbnails(bool show) {
412  showThumbnails_ = show;
413  }
414 
415  void setThumbnailLocalFilesOnly(bool value) {
416  Fm::ThumbnailLoader::setLocalFilesOnly(value);
417  }
418 
419  bool thumbnailLocalFilesOnly() {
420  return Fm::ThumbnailLoader::localFilesOnly();
421  }
422 
423  int maxThumbnailFileSize() {
424  return Fm::ThumbnailLoader::maxThumbnailFileSize();
425  }
426 
427  void setMaxThumbnailFileSize(int size) {
428  Fm::ThumbnailLoader::setMaxThumbnailFileSize(size);
429  }
430 
431  void setThumbnailIconSize(int thumbnailIconSize) {
432  thumbnailIconSize_ = thumbnailIconSize;
433  }
434 
435  bool siUnit() {
436  return siUnit_;
437  }
438 
439  void setSiUnit(bool siUnit) {
440  siUnit_ = siUnit;
441  // override libfm FmConfig settings. FIXME: should we do this?
442  fm_config->si_unit = (gboolean)siUnit_;
443  }
444 
445 private:
446  QString profileName_;
447  bool supportTrash_;
448 
449  // PCManFM specific
450  QString fallbackIconThemeName_;
451  bool useFallbackIconTheme_;
452 
453  int bookmarkOpenMethod_;
454  QString suCommand_;
455  QString terminal_;
456  bool mountOnStartup_;
457  bool mountRemovable_;
458  bool autoRun_;
459  bool closeOnUnmount_;
460 
461  int wallpaperMode_;
462  QString wallpaper_;
463  QColor desktopBgColor_;
464  QColor desktopFgColor_;
465  QColor desktopShadowColor_;
466  QFont desktopFont_;
467  bool showWmMenu_;
468 
469  bool desktopShowHidden_;
470  Qt::SortOrder desktopSortOrder_;
471  Fm::FolderModel::ColumnId desktopSortColumn_;
472 
473  bool alwaysShowTabs_;
474  bool showTabClose_;
475  bool rememberWindowSize_;
476  int fixedWindowWidth_;
477  int fixedWindowHeight_;
478  int lastWindowWidth_;
479  int lastWindowHeight_;
480  bool lastWindowMaximized_;
481  int splitterPos_;
482  int sidePaneMode_;
483 
484  Fm::FolderView::ViewMode viewMode_;
485  bool showHidden_;
486  Qt::SortOrder sortOrder_;
487  Fm::FolderModel::ColumnId sortColumn_;
488 
489  // settings for use with libfm
490  bool singleClick_;
491  int autoSelectionDelay_;
492  bool useTrash_;
493  bool confirmDelete_;
494  bool noUsbTrash_; // do not trash files on usb removable devices
495 
496  bool showThumbnails_;
497 
498  QString archiver_;
499  bool siUnit_;
500 
501  int bigIconSize_;
502  int smallIconSize_;
503  int sidePaneIconSize_;
504  int thumbnailIconSize_;
505 };
506 
507 }
508 
509 #endif // PCMANFM_SETTINGS_H
Definition: settings.h:33
Definition: application.h:38