PCManFM-Qt
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 <libfm-qt/folderview.h>
27 #include <libfm-qt/foldermodel.h>
28 #include "desktopwindow.h"
29 #include <libfm-qt/sidepane.h>
30 #include <libfm-qt/thumbnailloader.h>
31 
32 namespace PCManFM {
33 
34 enum OpenDirTargetType {
35  OpenInCurrentTab,
36  OpenInNewTab,
37  OpenInNewWindow,
38  OpenInLastActiveWindow
39 };
40 
41 class Settings : public QObject {
42  Q_OBJECT
43 public:
44  Settings();
45  virtual ~Settings();
46 
47  bool load(QString profile = "default");
48  bool save(QString profile = QString());
49 
50  bool loadFile(QString filePath);
51  bool saveFile(QString filePath);
52 
53  QString profileDir(QString profile, bool useFallback = false);
54 
55  // setter/getter functions
56  QString profileName() const {
57  return profileName_;
58  }
59 
60  bool supportTrash() const {
61  return supportTrash_;
62  }
63 
64  QString fallbackIconThemeName() const {
65  return fallbackIconThemeName_;
66  }
67 
68  bool useFallbackIconTheme() const {
69  return useFallbackIconTheme_;
70  }
71 
72  void setFallbackIconThemeName(QString iconThemeName) {
73  fallbackIconThemeName_ = iconThemeName;
74  }
75 
76  OpenDirTargetType bookmarkOpenMethod() {
77  return bookmarkOpenMethod_;
78  }
79 
80  void setBookmarkOpenMethod(OpenDirTargetType bookmarkOpenMethod) {
81  bookmarkOpenMethod_ = bookmarkOpenMethod;
82  }
83 
84  QString suCommand() const {
85  return suCommand_;
86  }
87 
88  void setSuCommand(QString suCommand) {
89  suCommand_ = suCommand;
90  }
91 
92  QString terminal() {
93  return terminal_;
94  }
95  void setTerminal(QString terminalCommand);
96 
97  QString archiver() const {
98  return archiver_;
99  }
100 
101  void setArchiver(QString archiver) {
102  archiver_ = archiver;
103  // override libfm FmConfig
104  g_free(fm_config->archiver);
105  fm_config->archiver = g_strdup(archiver_.toLocal8Bit().constData());
106  }
107 
108  bool mountOnStartup() const {
109  return mountOnStartup_;
110  }
111 
112  void setMountOnStartup(bool mountOnStartup) {
113  mountOnStartup_ = mountOnStartup;
114  }
115 
116  bool mountRemovable() {
117  return mountRemovable_;
118  }
119 
120  void setMountRemovable(bool mountRemovable) {
121  mountRemovable_ = mountRemovable;
122  }
123 
124  bool autoRun() const {
125  return autoRun_;
126  }
127 
128  void setAutoRun(bool autoRun) {
129  autoRun_ = autoRun;
130  }
131 
132  bool closeOnUnmount() const {
133  return closeOnUnmount_;
134  }
135 
136  void setCloseOnUnmount(bool value) {
137  closeOnUnmount_ = value;
138  }
139 
140  DesktopWindow::WallpaperMode wallpaperMode() const {
141  return DesktopWindow::WallpaperMode(wallpaperMode_);
142  }
143 
144  void setWallpaperMode(int wallpaperMode) {
145  wallpaperMode_ = wallpaperMode;
146  }
147 
148  QString wallpaper() const {
149  return wallpaper_;
150  }
151 
152  void setWallpaper(QString wallpaper) {
153  wallpaper_ = wallpaper;
154  }
155 
156  const QColor& desktopBgColor() const {
157  return desktopBgColor_;
158  }
159 
160  void setDesktopBgColor(QColor desktopBgColor) {
161  desktopBgColor_ = desktopBgColor;
162  }
163 
164  const QColor& desktopFgColor() const {
165  return desktopFgColor_;
166  }
167 
168  void setDesktopFgColor(QColor desktopFgColor) {
169  desktopFgColor_ = desktopFgColor;
170  }
171 
172  const QColor& desktopShadowColor() const {
173  return desktopShadowColor_;
174  }
175 
176  void setDesktopShadowColor(QColor desktopShadowColor) {
177  desktopShadowColor_ = desktopShadowColor;
178  }
179 
180  QFont desktopFont() const {
181  return desktopFont_;
182  }
183 
184  void setDesktopFont(QFont font) {
185  desktopFont_ = font;
186  }
187 
188  bool showWmMenu() const {
189  return showWmMenu_;
190  }
191 
192  void setShowWmMenu(bool value) {
193  showWmMenu_ = value;
194  }
195 
196  bool desktopShowHidden() const {
197  return desktopShowHidden_;
198  }
199 
200  void setDesktopShowHidden(bool desktopShowHidden) {
201  desktopShowHidden_ = desktopShowHidden;
202  }
203 
204  Qt::SortOrder desktopSortOrder() const {
205  return desktopSortOrder_;
206  }
207 
208  void setDesktopSortOrder(Qt::SortOrder desktopSortOrder) {
209  desktopSortOrder_ = desktopSortOrder;
210  }
211 
212  Fm::FolderModel::ColumnId desktopSortColumn() const {
213  return desktopSortColumn_;
214  }
215 
216  void setDesktopSortColumn(Fm::FolderModel::ColumnId desktopSortColumn) {
217  desktopSortColumn_ = desktopSortColumn;
218  }
219 
220  bool alwaysShowTabs() const {
221  return alwaysShowTabs_;
222  }
223 
224  void setAlwaysShowTabs(bool alwaysShowTabs) {
225  alwaysShowTabs_ = alwaysShowTabs;
226  }
227 
228  bool showTabClose() const {
229  return showTabClose_;
230  }
231 
232  void setShowTabClose(bool showTabClose) {
233  showTabClose_ = showTabClose;
234  }
235 
236  bool rememberWindowSize() const {
237  return rememberWindowSize_;
238  }
239 
240  void setRememberWindowSize(bool rememberWindowSize) {
241  rememberWindowSize_ = rememberWindowSize;
242  }
243 
244  int windowWidth() const {
245  if(rememberWindowSize_)
246  return lastWindowWidth_;
247  else
248  return fixedWindowWidth_;
249  }
250 
251  int windowHeight() const {
252  if(rememberWindowSize_)
253  return lastWindowHeight_;
254  else
255  return fixedWindowHeight_;
256  }
257 
258  bool windowMaximized() const {
259  if(rememberWindowSize_)
260  return lastWindowMaximized_;
261  else
262  return false;
263  }
264 
265  int fixedWindowWidth() const {
266  return fixedWindowWidth_;
267  }
268 
269  void setFixedWindowWidth(int fixedWindowWidth) {
270  fixedWindowWidth_ = fixedWindowWidth;
271  }
272 
273  int fixedWindowHeight() const {
274  return fixedWindowHeight_;
275  }
276 
277  void setFixedWindowHeight(int fixedWindowHeight) {
278  fixedWindowHeight_ = fixedWindowHeight;
279  }
280 
281  void setLastWindowWidth(int lastWindowWidth) {
282  lastWindowWidth_ = lastWindowWidth;
283  }
284 
285  void setLastWindowHeight(int lastWindowHeight) {
286  lastWindowHeight_ = lastWindowHeight;
287  }
288 
289  void setLastWindowMaximized(bool lastWindowMaximized) {
290  lastWindowMaximized_ = lastWindowMaximized;
291  }
292 
293  int splitterPos() const {
294  return splitterPos_;
295  }
296 
297  void setSplitterPos(int splitterPos) {
298  splitterPos_ = splitterPos;
299  }
300 
301  Fm::SidePane::Mode sidePaneMode() const {
302  return sidePaneMode_;
303  }
304 
305  void setSidePaneMode(Fm::SidePane::Mode sidePaneMode) {
306  sidePaneMode_ = sidePaneMode;
307  }
308 
309  bool showMenuBar() const {
310  return showMenuBar_;
311  }
312 
313  void setShowMenuBar(bool showMenuBar) {
314  showMenuBar_ = showMenuBar;
315  }
316 
317  bool fullWidthTabBar() const {
318  return fullWidthTabBar_;
319  }
320 
321  void setFullWidthTabBar(bool fullWith) {
322  fullWidthTabBar_ = fullWith;
323  }
324 
325  Fm::FolderView::ViewMode viewMode() const {
326  return viewMode_;
327  }
328 
329  void setViewMode(Fm::FolderView::ViewMode viewMode) {
330  viewMode_ = viewMode;
331  }
332 
333  bool showHidden() const {
334  return showHidden_;
335  }
336 
337  void setShowHidden(bool showHidden) {
338  showHidden_ = showHidden;
339  }
340 
341  bool placesHome() const {
342  return placesHome_;
343  }
344 
345  void setPlacesHome(bool placesHome) {
346  placesHome_ = placesHome;
347  }
348 
349  bool placesDesktop() const {
350  return placesDesktop_;
351  }
352 
353  void setPlacesDesktop(bool placesDesktop) {
354  placesDesktop_ = placesDesktop;
355  }
356 
357  bool placesApplications() const {
358  return placesApplications_;
359  }
360 
361  void setPlacesApplications(bool placesApplications) {
362  placesApplications_ = placesApplications;
363  }
364 
365  bool placesTrash() const {
366  return placesTrash_;
367  }
368 
369  void setPlacesTrash(bool placesTrash) {
370  placesTrash_ = placesTrash;
371  }
372 
373  bool placesRoot() const {
374  return placesRoot_;
375  }
376 
377  void setPlacesRoot(bool placesRoot) {
378  placesRoot_ = placesRoot;
379  }
380 
381  bool placesComputer() const {
382  return placesComputer_;
383  }
384 
385  void setPlacesComputer(bool placesComputer) {
386  placesComputer_ = placesComputer;
387  }
388 
389  bool placesNetwork() const {
390  return placesNetwork_;
391  }
392 
393  void setPlacesNetwork(bool placesNetwork) {
394  placesNetwork_ = placesNetwork;
395  }
396 
397 
398  Qt::SortOrder sortOrder() const {
399  return sortOrder_;
400  }
401 
402  void setSortOrder(Qt::SortOrder sortOrder) {
403  sortOrder_ = sortOrder;
404  }
405 
406  Fm::FolderModel::ColumnId sortColumn() const {
407  return sortColumn_;
408  }
409 
410  void setSortColumn(Fm::FolderModel::ColumnId sortColumn) {
411  sortColumn_ = sortColumn;
412  }
413 
414  bool sortFolderFirst() const {
415  return sortFolderFirst_;
416  }
417 
418  void setSortFolderFirst(bool folderFirst) {
419  sortFolderFirst_ = folderFirst;
420  }
421 
422  bool showFilter() const {
423  return showFilter_;
424  }
425 
426  void setShowFilter(bool value) {
427  showFilter_ = value;
428  }
429 
430  // settings for use with libfm
431  bool singleClick() const {
432  return singleClick_;
433  }
434 
435  void setSingleClick(bool singleClick) {
436  singleClick_ = singleClick;
437  }
438 
439  int autoSelectionDelay() const {
440  return autoSelectionDelay_;
441  }
442 
443  void setAutoSelectionDelay(int value) {
444  autoSelectionDelay_ = value;
445  }
446 
447  bool useTrash() const {
448  if(!supportTrash_)
449  return false;
450  return useTrash_;
451  }
452 
453  void setUseTrash(bool useTrash) {
454  useTrash_ = useTrash;
455  }
456 
457  bool confirmDelete() const {
458  return confirmDelete_;
459  }
460 
461  void setConfirmDelete(bool confirmDelete) {
462  confirmDelete_ = confirmDelete;
463  }
464 
465  bool noUsbTrash() const {
466  return noUsbTrash_;
467  }
468 
469  void setNoUsbTrash(bool noUsbTrash) {
470  noUsbTrash_ = noUsbTrash;
471  fm_config->no_usb_trash = noUsbTrash_; // also set this to libfm since FmFileOpsJob reads this config value before trashing files.
472  }
473 
474  bool confirmTrash() const {
475  return confirmTrash_;
476  }
477 
478  void setConfirmTrash(bool value) {
479  confirmTrash_ = value;
480  }
481 
482  bool quickExec() const {
483  return quickExec_;
484  }
485 
486  void setQuickExec(bool value) {
487  quickExec_ = value;
488  fm_config->quick_exec = quickExec_;
489  }
490 
491  // bool thumbnailLocal_;
492  // bool thumbnailMax;
493 
494  int bigIconSize() const {
495  return bigIconSize_;
496  }
497 
498  void setBigIconSize(int bigIconSize) {
499  bigIconSize_ = bigIconSize;
500  }
501 
502  int smallIconSize() const {
503  return smallIconSize_;
504  }
505 
506  void setSmallIconSize(int smallIconSize) {
507  smallIconSize_ = smallIconSize;
508  }
509 
510  int sidePaneIconSize() const {
511  return sidePaneIconSize_;
512  }
513 
514  void setSidePaneIconSize(int sidePaneIconSize) {
515  sidePaneIconSize_ = sidePaneIconSize;
516  }
517 
518  int thumbnailIconSize() const {
519  return thumbnailIconSize_;
520  }
521 
522  QSize folderViewCellMargins() const {
523  return folderViewCellMargins_;
524  }
525 
526  void setFolderViewCellMargins(QSize size) {
527  folderViewCellMargins_ = size;
528  }
529 
530  QSize desktopCellMargins() const {
531  return desktopCellMargins_;
532  }
533 
534  void setDesktopCellMargins(QSize size) {
535  desktopCellMargins_ = size;
536  }
537 
538 
539  bool showThumbnails() {
540  return showThumbnails_;
541  }
542 
543  void setShowThumbnails(bool show) {
544  showThumbnails_ = show;
545  }
546 
547  void setThumbnailLocalFilesOnly(bool value) {
548  Fm::ThumbnailLoader::setLocalFilesOnly(value);
549  }
550 
551  bool thumbnailLocalFilesOnly() {
552  return Fm::ThumbnailLoader::localFilesOnly();
553  }
554 
555  int maxThumbnailFileSize() {
556  return Fm::ThumbnailLoader::maxThumbnailFileSize();
557  }
558 
559  void setMaxThumbnailFileSize(int size) {
560  Fm::ThumbnailLoader::setMaxThumbnailFileSize(size);
561  }
562 
563  void setThumbnailIconSize(int thumbnailIconSize) {
564  thumbnailIconSize_ = thumbnailIconSize;
565  }
566 
567  bool siUnit() {
568  return siUnit_;
569  }
570 
571  void setSiUnit(bool siUnit) {
572  siUnit_ = siUnit;
573  // override libfm FmConfig settings. FIXME: should we do this?
574  fm_config->si_unit = (gboolean)siUnit_;
575  }
576 
577  bool backupAsHidden() const {
578  return backupAsHidden_;
579  }
580 
581  void setBackupAsHidden(bool value) {
582  backupAsHidden_ = value;
583  fm_config->backup_as_hidden = backupAsHidden_; // also set this to libfm since fm_file_info_is_hidden() reads this value internally.
584  }
585 
586  bool showFullNames() const {
587  return showFullNames_;
588  }
589 
590  void setShowFullNames(bool value) {
591  showFullNames_ = value;
592  }
593 
594  bool shadowHidden() const {
595  return shadowHidden_;
596  }
597 
598  void setShadowHidden(bool value) {
599  shadowHidden_ = value;
600  }
601 
602  bool onlyUserTemplates() const {
603  return onlyUserTemplates_;
604  }
605 
606  void setOnlyUserTemplates(bool value) {
607  onlyUserTemplates_ = value;
608  fm_config->only_user_templates = onlyUserTemplates_;
609  }
610 
611  bool templateTypeOnce() const {
612  return templateTypeOnce_;
613  }
614 
615  void setTemplateTypeOnce(bool value) {
616  templateTypeOnce_ = value;
617  fm_config->template_type_once = templateTypeOnce_;
618  }
619 
620  bool templateRunApp() const {
621  return templateRunApp_;
622  }
623 
624  void setTemplateRunApp(bool value) {
625  templateRunApp_ = value;
626  fm_config->template_run_app = templateRunApp_;
627  }
628 
629 
630 private:
631  QString profileName_;
632  bool supportTrash_;
633 
634  // PCManFM specific
635  QString fallbackIconThemeName_;
636  bool useFallbackIconTheme_;
637 
638  OpenDirTargetType bookmarkOpenMethod_;
639  QString suCommand_;
640  QString terminal_;
641  bool mountOnStartup_;
642  bool mountRemovable_;
643  bool autoRun_;
644  bool closeOnUnmount_;
645 
646  int wallpaperMode_;
647  QString wallpaper_;
648  QColor desktopBgColor_;
649  QColor desktopFgColor_;
650  QColor desktopShadowColor_;
651  QFont desktopFont_;
652  bool showWmMenu_;
653 
654  bool desktopShowHidden_;
655  Qt::SortOrder desktopSortOrder_;
656  Fm::FolderModel::ColumnId desktopSortColumn_;
657 
658  bool alwaysShowTabs_;
659  bool showTabClose_;
660  bool rememberWindowSize_;
661  int fixedWindowWidth_;
662  int fixedWindowHeight_;
663  int lastWindowWidth_;
664  int lastWindowHeight_;
665  bool lastWindowMaximized_;
666  int splitterPos_;
667  Fm::SidePane::Mode sidePaneMode_;
668  bool showMenuBar_;
669  bool fullWidthTabBar_;
670 
671  Fm::FolderView::ViewMode viewMode_;
672  bool showHidden_;
673  Qt::SortOrder sortOrder_;
674  Fm::FolderModel::ColumnId sortColumn_;
675  bool sortFolderFirst_;
676  bool showFilter_;
677 
678  // settings for use with libfm
679  bool singleClick_;
680  int autoSelectionDelay_;
681  bool useTrash_;
682  bool confirmDelete_;
683  bool noUsbTrash_; // do not trash files on usb removable devices
684  bool confirmTrash_; // Confirm before moving files into "trash can"
685  bool quickExec_; // Don't ask options on launch executable file
686 
687  bool showThumbnails_;
688 
689  QString archiver_;
690  bool siUnit_;
691  bool backupAsHidden_;
692  bool showFullNames_;
693  bool shadowHidden_;
694 
695  bool placesHome_;
696  bool placesDesktop_;
697  bool placesApplications_;
698  bool placesTrash_;
699  bool placesRoot_;
700  bool placesComputer_;
701  bool placesNetwork_;
702 
703  int bigIconSize_;
704  int smallIconSize_;
705  int sidePaneIconSize_;
706  int thumbnailIconSize_;
707 
708  bool onlyUserTemplates_;
709  bool templateTypeOnce_;
710  bool templateRunApp_;
711 
712  QSize folderViewCellMargins_;
713  QSize desktopCellMargins_;
714 };
715 
716 }
717 
718 #endif // PCMANFM_SETTINGS_H
Definition: settings.h:41
Definition: application.cpp:55