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-qt/folderview.h> 26 #include <libfm-qt/foldermodel.h> 27 #include "desktopwindow.h" 28 #include <libfm-qt/sidepane.h> 29 #include <libfm-qt/core/thumbnailjob.h> 30 #include <libfm-qt/core/archiver.h> 31 #include <libfm-qt/core/legacy/fm-config.h> 32 33 namespace PCManFM { 34 35 enum OpenDirTargetType { 36 OpenInCurrentTab, 37 OpenInNewTab, 38 OpenInNewWindow, 39 OpenInLastActiveWindow 40 }; 41 42 class FolderSettings { 43 public: FolderSettings()44 FolderSettings(): 45 isCustomized_(false), 46 // NOTE: The default values of the following variables should be 47 // the same as those of their corresponding variables in Settings: 48 sortOrder_(Qt::AscendingOrder), 49 sortColumn_(Fm::FolderModel::ColumnFileName), 50 viewMode_(Fm::FolderView::IconMode), 51 showHidden_(false), 52 sortFolderFirst_(true), 53 sortHiddenLast_(false), 54 sortCaseSensitive_(true), 55 recursive_(false) { 56 } 57 isCustomized()58 bool isCustomized() const { 59 return isCustomized_; 60 } 61 setCustomized(bool value)62 void setCustomized(bool value) { 63 isCustomized_ = value; 64 } 65 sortOrder()66 Qt::SortOrder sortOrder() const { 67 return sortOrder_; 68 } 69 setSortOrder(Qt::SortOrder value)70 void setSortOrder(Qt::SortOrder value) { 71 sortOrder_ = value; 72 } 73 sortColumn()74 Fm::FolderModel::ColumnId sortColumn() const { 75 return sortColumn_; 76 } 77 setSortColumn(Fm::FolderModel::ColumnId value)78 void setSortColumn(Fm::FolderModel::ColumnId value) { 79 sortColumn_ = value; 80 } 81 viewMode()82 Fm::FolderView::ViewMode viewMode() const { 83 return viewMode_; 84 } 85 setViewMode(Fm::FolderView::ViewMode value)86 void setViewMode(Fm::FolderView::ViewMode value) { 87 viewMode_ = value; 88 } 89 sortFolderFirst()90 bool sortFolderFirst() const { 91 return sortFolderFirst_; 92 } 93 setSortFolderFirst(bool value)94 void setSortFolderFirst(bool value) { 95 sortFolderFirst_ = value; 96 } 97 sortHiddenLast()98 bool sortHiddenLast() const { 99 return sortHiddenLast_; 100 } 101 setSortHiddenLast(bool value)102 void setSortHiddenLast(bool value) { 103 sortHiddenLast_ = value; 104 } 105 showHidden()106 bool showHidden() const { 107 return showHidden_; 108 } 109 setShowHidden(bool value)110 void setShowHidden(bool value) { 111 showHidden_ = value; 112 } 113 sortCaseSensitive()114 bool sortCaseSensitive() const { 115 return sortCaseSensitive_; 116 } 117 setSortCaseSensitive(bool value)118 void setSortCaseSensitive(bool value) { 119 sortCaseSensitive_ = value; 120 } 121 recursive()122 bool recursive() const { 123 return recursive_; 124 } 125 setRecursive(bool value)126 void setRecursive(bool value) { 127 recursive_ = value; 128 } 129 inheritedPath()130 Fm::FilePath inheritedPath() const { 131 return inheritedPath_; 132 } 133 seInheritedPath(const Fm::FilePath & path)134 void seInheritedPath(const Fm::FilePath& path) { 135 inheritedPath_ = std::move(path); 136 } 137 138 139 private: 140 bool isCustomized_; 141 Qt::SortOrder sortOrder_; 142 Fm::FolderModel::ColumnId sortColumn_; 143 Fm::FolderView::ViewMode viewMode_; 144 bool showHidden_; 145 bool sortFolderFirst_; 146 bool sortHiddenLast_; 147 bool sortCaseSensitive_; 148 bool recursive_; 149 Fm::FilePath inheritedPath_; 150 // columns? 151 }; 152 153 154 class Settings : public QObject { 155 Q_OBJECT 156 public: 157 enum IconType { 158 Small, 159 Big, 160 Thumbnail 161 }; 162 163 Settings(); 164 virtual ~Settings(); 165 166 bool load(QString profile = QStringLiteral("default")); 167 bool save(QString profile = QString()); 168 169 bool loadFile(QString filePath); 170 bool saveFile(QString filePath); 171 172 static QString xdgUserConfigDir(); 173 static const QList<int> & iconSizes(IconType type); 174 175 QString profileDir(QString profile, bool useFallback = false); 176 177 // setter/getter functions profileName()178 QString profileName() const { 179 return profileName_; 180 } 181 supportTrash()182 bool supportTrash() const { 183 return supportTrash_; 184 } 185 fallbackIconThemeName()186 QString fallbackIconThemeName() const { 187 return fallbackIconThemeName_; 188 } 189 useFallbackIconTheme()190 bool useFallbackIconTheme() const { 191 return useFallbackIconTheme_; 192 } 193 setFallbackIconThemeName(QString iconThemeName)194 void setFallbackIconThemeName(QString iconThemeName) { 195 fallbackIconThemeName_ = iconThemeName; 196 } 197 singleWindowMode()198 bool singleWindowMode() const { 199 return singleWindowMode_; 200 } 201 setSingleWindowMode(bool singleWindowMode)202 void setSingleWindowMode(bool singleWindowMode) { 203 singleWindowMode_ = singleWindowMode; 204 } 205 bookmarkOpenMethod()206 OpenDirTargetType bookmarkOpenMethod() { 207 return bookmarkOpenMethod_; 208 } 209 setBookmarkOpenMethod(OpenDirTargetType bookmarkOpenMethod)210 void setBookmarkOpenMethod(OpenDirTargetType bookmarkOpenMethod) { 211 bookmarkOpenMethod_ = bookmarkOpenMethod; 212 } 213 suCommand()214 QString suCommand() const { 215 return suCommand_; 216 } 217 setSuCommand(QString suCommand)218 void setSuCommand(QString suCommand) { 219 suCommand_ = suCommand; 220 } 221 terminal()222 QString terminal() { 223 return terminal_; 224 } 225 void setTerminal(QString terminalCommand); 226 archiver()227 QString archiver() const { 228 return archiver_; 229 } 230 setArchiver(QString archiver)231 void setArchiver(QString archiver) { 232 archiver_ = archiver; 233 Fm::Archiver::setDefaultArchiverByName(archiver_.toLocal8Bit().constData()); 234 } 235 mountOnStartup()236 bool mountOnStartup() const { 237 return mountOnStartup_; 238 } 239 setMountOnStartup(bool mountOnStartup)240 void setMountOnStartup(bool mountOnStartup) { 241 mountOnStartup_ = mountOnStartup; 242 } 243 mountRemovable()244 bool mountRemovable() { 245 return mountRemovable_; 246 } 247 setMountRemovable(bool mountRemovable)248 void setMountRemovable(bool mountRemovable) { 249 mountRemovable_ = mountRemovable; 250 } 251 autoRun()252 bool autoRun() const { 253 return autoRun_; 254 } 255 setAutoRun(bool autoRun)256 void setAutoRun(bool autoRun) { 257 autoRun_ = autoRun; 258 } 259 closeOnUnmount()260 bool closeOnUnmount() const { 261 return closeOnUnmount_; 262 } 263 setCloseOnUnmount(bool value)264 void setCloseOnUnmount(bool value) { 265 closeOnUnmount_ = value; 266 } 267 wallpaperMode()268 DesktopWindow::WallpaperMode wallpaperMode() const { 269 return DesktopWindow::WallpaperMode(wallpaperMode_); 270 } 271 setWallpaperMode(int wallpaperMode)272 void setWallpaperMode(int wallpaperMode) { 273 wallpaperMode_ = wallpaperMode; 274 } 275 wallpaper()276 QString wallpaper() const { 277 return wallpaper_; 278 } 279 setWallpaper(QString wallpaper)280 void setWallpaper(QString wallpaper) { 281 wallpaper_ = wallpaper; 282 } 283 wallpaperDialogSize()284 QSize wallpaperDialogSize() const { 285 return wallpaperDialogSize_; 286 } 287 setWallpaperDialogSize(const QSize & size)288 void setWallpaperDialogSize(const QSize& size) { 289 wallpaperDialogSize_ = size; 290 } 291 wallpaperDialogSplitterPos()292 int wallpaperDialogSplitterPos() const { 293 return wallpaperDialogSplitterPos_; 294 } 295 setWallpaperDialogSplitterPos(int pos)296 void setWallpaperDialogSplitterPos(int pos) { 297 wallpaperDialogSplitterPos_ = pos; 298 } 299 wallpaperDir()300 QString wallpaperDir() const { 301 return wallpaperDir_; 302 } 303 setLastSlide(QString wallpaper)304 void setLastSlide(QString wallpaper) { 305 lastSlide_ = wallpaper; 306 } 307 lastSlide()308 QString lastSlide() const { 309 return lastSlide_; 310 } 311 setWallpaperDir(QString dir)312 void setWallpaperDir(QString dir) { 313 wallpaperDir_ = dir; 314 } 315 slideShowInterval()316 int slideShowInterval() const { 317 return slideShowInterval_; 318 } 319 setSlideShowInterval(int interval)320 void setSlideShowInterval(int interval) { 321 slideShowInterval_ = interval; 322 } 323 wallpaperRandomize()324 bool wallpaperRandomize() const { 325 return wallpaperRandomize_; 326 } 327 setWallpaperRandomize(bool randomize)328 void setWallpaperRandomize(bool randomize) { 329 wallpaperRandomize_ = randomize; 330 } 331 transformWallpaper()332 bool transformWallpaper() const { 333 return transformWallpaper_; 334 } 335 setTransformWallpaper(bool tr)336 void setTransformWallpaper(bool tr) { 337 transformWallpaper_ = tr; 338 } 339 perScreenWallpaper()340 bool perScreenWallpaper() const { 341 return perScreenWallpaper_; 342 } 343 setPerScreenWallpaper(bool tr)344 void setPerScreenWallpaper(bool tr) { 345 perScreenWallpaper_ = tr; 346 } 347 desktopBgColor()348 const QColor& desktopBgColor() const { 349 return desktopBgColor_; 350 } 351 setDesktopBgColor(QColor desktopBgColor)352 void setDesktopBgColor(QColor desktopBgColor) { 353 desktopBgColor_ = desktopBgColor; 354 } 355 desktopFgColor()356 const QColor& desktopFgColor() const { 357 return desktopFgColor_; 358 } 359 setDesktopFgColor(QColor desktopFgColor)360 void setDesktopFgColor(QColor desktopFgColor) { 361 desktopFgColor_ = desktopFgColor; 362 } 363 desktopShadowColor()364 const QColor& desktopShadowColor() const { 365 return desktopShadowColor_; 366 } 367 setDesktopShadowColor(QColor desktopShadowColor)368 void setDesktopShadowColor(QColor desktopShadowColor) { 369 desktopShadowColor_ = desktopShadowColor; 370 } 371 desktopFont()372 QFont desktopFont() const { 373 return desktopFont_; 374 } 375 setDesktopFont(QFont font)376 void setDesktopFont(QFont font) { 377 desktopFont_ = font; 378 } 379 desktopIconSize()380 int desktopIconSize() const { 381 return desktopIconSize_; 382 } 383 setDesktopIconSize(int desktopIconSize)384 void setDesktopIconSize(int desktopIconSize) { 385 desktopIconSize_ = desktopIconSize; 386 } 387 desktopShortcuts()388 QStringList desktopShortcuts() const { 389 return desktopShortcuts_; 390 } 391 setDesktopShortcuts(const QStringList & list)392 void setDesktopShortcuts(const QStringList& list) { 393 desktopShortcuts_ = list; 394 } 395 desktopShowHidden()396 bool desktopShowHidden() const { 397 return desktopShowHidden_; 398 } 399 setDesktopShowHidden(bool desktopShowHidden)400 void setDesktopShowHidden(bool desktopShowHidden) { 401 desktopShowHidden_ = desktopShowHidden; 402 } 403 desktopHideItems()404 bool desktopHideItems() const { 405 return desktopHideItems_; 406 } 407 setDesktopHideItems(bool hide)408 void setDesktopHideItems(bool hide) { 409 desktopHideItems_ = hide; 410 } 411 desktopSortOrder()412 Qt::SortOrder desktopSortOrder() const { 413 return desktopSortOrder_; 414 } 415 setDesktopSortOrder(Qt::SortOrder desktopSortOrder)416 void setDesktopSortOrder(Qt::SortOrder desktopSortOrder) { 417 desktopSortOrder_ = desktopSortOrder; 418 } 419 desktopSortColumn()420 Fm::FolderModel::ColumnId desktopSortColumn() const { 421 return desktopSortColumn_; 422 } 423 setDesktopSortColumn(Fm::FolderModel::ColumnId desktopSortColumn)424 void setDesktopSortColumn(Fm::FolderModel::ColumnId desktopSortColumn) { 425 desktopSortColumn_ = desktopSortColumn; 426 } 427 desktopSortFolderFirst()428 bool desktopSortFolderFirst() const { 429 return desktopSortFolderFirst_; 430 } 431 setDesktopSortFolderFirst(bool desktopFolderFirst)432 void setDesktopSortFolderFirst(bool desktopFolderFirst) { 433 desktopSortFolderFirst_ = desktopFolderFirst; 434 } 435 desktopSortHiddenLast()436 bool desktopSortHiddenLast() const { 437 return desktopSortHiddenLast_; 438 } 439 setDesktopSortHiddenLast(bool desktopHiddenLast)440 void setDesktopSortHiddenLast(bool desktopHiddenLast) { 441 desktopSortHiddenLast_ = desktopHiddenLast; 442 } 443 alwaysShowTabs()444 bool alwaysShowTabs() const { 445 return alwaysShowTabs_; 446 } 447 setAlwaysShowTabs(bool alwaysShowTabs)448 void setAlwaysShowTabs(bool alwaysShowTabs) { 449 alwaysShowTabs_ = alwaysShowTabs; 450 } 451 showTabClose()452 bool showTabClose() const { 453 return showTabClose_; 454 } 455 setShowTabClose(bool showTabClose)456 void setShowTabClose(bool showTabClose) { 457 showTabClose_ = showTabClose; 458 } 459 switchToNewTab()460 bool switchToNewTab() const { 461 return switchToNewTab_; 462 } 463 setSwitchToNewTab(bool showTabClose)464 void setSwitchToNewTab(bool showTabClose) { 465 switchToNewTab_ = showTabClose; 466 } 467 reopenLastTabs()468 bool reopenLastTabs() const { 469 return reopenLastTabs_; 470 } 471 setReopenLastTabs(bool reopenLastTabs)472 void setReopenLastTabs(bool reopenLastTabs) { 473 reopenLastTabs_ = reopenLastTabs; 474 } 475 tabPaths()476 QStringList tabPaths() const { 477 return tabPaths_; 478 } 479 setTabPaths(const QStringList & tabPaths)480 void setTabPaths(const QStringList& tabPaths) { 481 tabPaths_ = tabPaths; 482 } 483 rememberWindowSize()484 bool rememberWindowSize() const { 485 return rememberWindowSize_; 486 } 487 setRememberWindowSize(bool rememberWindowSize)488 void setRememberWindowSize(bool rememberWindowSize) { 489 rememberWindowSize_ = rememberWindowSize; 490 } 491 windowWidth()492 int windowWidth() const { 493 if(rememberWindowSize_) { 494 return lastWindowWidth_; 495 } 496 else { 497 return fixedWindowWidth_; 498 } 499 } 500 windowHeight()501 int windowHeight() const { 502 if(rememberWindowSize_) { 503 return lastWindowHeight_; 504 } 505 else { 506 return fixedWindowHeight_; 507 } 508 } 509 windowMaximized()510 bool windowMaximized() const { 511 if(rememberWindowSize_) { 512 return lastWindowMaximized_; 513 } 514 else { 515 return false; 516 } 517 } 518 fixedWindowWidth()519 int fixedWindowWidth() const { 520 return fixedWindowWidth_; 521 } 522 setFixedWindowWidth(int fixedWindowWidth)523 void setFixedWindowWidth(int fixedWindowWidth) { 524 fixedWindowWidth_ = fixedWindowWidth; 525 } 526 fixedWindowHeight()527 int fixedWindowHeight() const { 528 return fixedWindowHeight_; 529 } 530 setFixedWindowHeight(int fixedWindowHeight)531 void setFixedWindowHeight(int fixedWindowHeight) { 532 fixedWindowHeight_ = fixedWindowHeight; 533 } 534 setLastWindowWidth(int lastWindowWidth)535 void setLastWindowWidth(int lastWindowWidth) { 536 lastWindowWidth_ = lastWindowWidth; 537 } 538 setLastWindowHeight(int lastWindowHeight)539 void setLastWindowHeight(int lastWindowHeight) { 540 lastWindowHeight_ = lastWindowHeight; 541 } 542 setLastWindowMaximized(bool lastWindowMaximized)543 void setLastWindowMaximized(bool lastWindowMaximized) { 544 lastWindowMaximized_ = lastWindowMaximized; 545 } 546 splitterPos()547 int splitterPos() const { 548 return splitterPos_; 549 } 550 setSplitterPos(int splitterPos)551 void setSplitterPos(int splitterPos) { 552 splitterPos_ = splitterPos; 553 } 554 isSidePaneVisible()555 bool isSidePaneVisible() const { 556 return sidePaneVisible_; 557 } 558 showSidePane(bool show)559 void showSidePane(bool show) { 560 sidePaneVisible_ = show; 561 } 562 sidePaneMode()563 Fm::SidePane::Mode sidePaneMode() const { 564 return sidePaneMode_; 565 } 566 setSidePaneMode(Fm::SidePane::Mode sidePaneMode)567 void setSidePaneMode(Fm::SidePane::Mode sidePaneMode) { 568 sidePaneMode_ = sidePaneMode; 569 } 570 showMenuBar()571 bool showMenuBar() const { 572 return showMenuBar_; 573 } 574 setShowMenuBar(bool showMenuBar)575 void setShowMenuBar(bool showMenuBar) { 576 showMenuBar_ = showMenuBar; 577 } 578 splitView()579 bool splitView() const { 580 return splitView_; 581 } 582 setSplitView(bool split)583 void setSplitView(bool split) { 584 splitView_ = split; 585 } 586 viewMode()587 Fm::FolderView::ViewMode viewMode() const { 588 return viewMode_; 589 } 590 setViewMode(Fm::FolderView::ViewMode viewMode)591 void setViewMode(Fm::FolderView::ViewMode viewMode) { 592 viewMode_ = viewMode; 593 } 594 showHidden()595 bool showHidden() const { 596 return showHidden_; 597 } 598 setShowHidden(bool showHidden)599 void setShowHidden(bool showHidden) { 600 showHidden_ = showHidden; 601 } 602 sortCaseSensitive()603 bool sortCaseSensitive() const { 604 return sortCaseSensitive_; 605 } 606 setSortCaseSensitive(bool value)607 void setSortCaseSensitive(bool value) { 608 sortCaseSensitive_ = value; 609 } 610 getHiddenPlaces()611 QSet<QString> getHiddenPlaces() const { 612 return hiddenPlaces_; 613 } 614 setHiddenPlace(const QString & str,bool hide)615 void setHiddenPlace(const QString& str, bool hide) { 616 if(hide) { 617 hiddenPlaces_ << str; 618 } 619 else { 620 hiddenPlaces_.remove(str); 621 } 622 } 623 sortOrder()624 Qt::SortOrder sortOrder() const { 625 return sortOrder_; 626 } 627 setSortOrder(Qt::SortOrder sortOrder)628 void setSortOrder(Qt::SortOrder sortOrder) { 629 sortOrder_ = sortOrder; 630 } 631 sortColumn()632 Fm::FolderModel::ColumnId sortColumn() const { 633 return sortColumn_; 634 } 635 setSortColumn(Fm::FolderModel::ColumnId sortColumn)636 void setSortColumn(Fm::FolderModel::ColumnId sortColumn) { 637 sortColumn_ = sortColumn; 638 } 639 sortFolderFirst()640 bool sortFolderFirst() const { 641 return sortFolderFirst_; 642 } 643 setSortFolderFirst(bool folderFirst)644 void setSortFolderFirst(bool folderFirst) { 645 sortFolderFirst_ = folderFirst; 646 } 647 sortHiddenLast()648 bool sortHiddenLast() const { 649 return sortHiddenLast_; 650 } 651 setSortHiddenLast(bool hiddenLast)652 void setSortHiddenLast(bool hiddenLast) { 653 sortHiddenLast_ = hiddenLast; 654 } 655 showFilter()656 bool showFilter() const { 657 return showFilter_; 658 } 659 setShowFilter(bool value)660 void setShowFilter(bool value) { 661 showFilter_ = value; 662 } 663 pathBarButtons()664 bool pathBarButtons() const { 665 return pathBarButtons_; 666 } 667 setPathBarButtons(bool value)668 void setPathBarButtons(bool value) { 669 pathBarButtons_ = value; 670 } 671 672 // settings for use with libfm singleClick()673 bool singleClick() const { 674 return singleClick_; 675 } 676 setSingleClick(bool singleClick)677 void setSingleClick(bool singleClick) { 678 singleClick_ = singleClick; 679 } 680 autoSelectionDelay()681 int autoSelectionDelay() const { 682 return autoSelectionDelay_; 683 } 684 setAutoSelectionDelay(int value)685 void setAutoSelectionDelay(int value) { 686 autoSelectionDelay_ = value; 687 } 688 ctrlRightClick()689 bool ctrlRightClick() const { 690 return ctrlRightClick_; 691 } 692 setCtrlRightClick(bool value)693 void setCtrlRightClick(bool value) { 694 ctrlRightClick_ = value; 695 } 696 useTrash()697 bool useTrash() const { 698 if(!supportTrash_) { 699 return false; 700 } 701 return useTrash_; 702 } 703 setUseTrash(bool useTrash)704 void setUseTrash(bool useTrash) { 705 useTrash_ = useTrash; 706 } 707 confirmDelete()708 bool confirmDelete() const { 709 return confirmDelete_; 710 } 711 setConfirmDelete(bool confirmDelete)712 void setConfirmDelete(bool confirmDelete) { 713 confirmDelete_ = confirmDelete; 714 } 715 noUsbTrash()716 bool noUsbTrash() const { 717 return noUsbTrash_; 718 } 719 setNoUsbTrash(bool noUsbTrash)720 void setNoUsbTrash(bool noUsbTrash) { 721 noUsbTrash_ = noUsbTrash; 722 fm_config->no_usb_trash = noUsbTrash_; // also set this to libfm since FmFileOpsJob reads this config value before trashing files. 723 } 724 confirmTrash()725 bool confirmTrash() const { 726 return confirmTrash_; 727 } 728 setConfirmTrash(bool value)729 void setConfirmTrash(bool value) { 730 confirmTrash_ = value; 731 } 732 quickExec()733 bool quickExec() const { 734 return quickExec_; 735 } 736 setQuickExec(bool value)737 void setQuickExec(bool value) { 738 quickExec_ = value; 739 fm_config->quick_exec = quickExec_; 740 } 741 selectNewFiles()742 bool selectNewFiles() const { 743 return selectNewFiles_; 744 } 745 setSelectNewFiles(bool value)746 void setSelectNewFiles(bool value) { 747 selectNewFiles_ = value; 748 } 749 bigIconSize()750 int bigIconSize() const { 751 return bigIconSize_; 752 } 753 setBigIconSize(int bigIconSize)754 void setBigIconSize(int bigIconSize) { 755 bigIconSize_ = bigIconSize; 756 } 757 smallIconSize()758 int smallIconSize() const { 759 return smallIconSize_; 760 } 761 setSmallIconSize(int smallIconSize)762 void setSmallIconSize(int smallIconSize) { 763 smallIconSize_ = smallIconSize; 764 } 765 sidePaneIconSize()766 int sidePaneIconSize() const { 767 return sidePaneIconSize_; 768 } 769 setSidePaneIconSize(int sidePaneIconSize)770 void setSidePaneIconSize(int sidePaneIconSize) { 771 sidePaneIconSize_ = sidePaneIconSize; 772 } 773 thumbnailIconSize()774 int thumbnailIconSize() const { 775 return thumbnailIconSize_; 776 } 777 folderViewCellMargins()778 QSize folderViewCellMargins() const { 779 return folderViewCellMargins_; 780 } 781 setFolderViewCellMargins(QSize size)782 void setFolderViewCellMargins(QSize size) { 783 folderViewCellMargins_ = size; 784 } 785 desktopCellMargins()786 QSize desktopCellMargins() const { 787 return desktopCellMargins_; 788 } 789 setDesktopCellMargins(QSize size)790 void setDesktopCellMargins(QSize size) { 791 desktopCellMargins_ = size; 792 } 793 openWithDefaultFileManager()794 bool openWithDefaultFileManager() const { 795 return openWithDefaultFileManager_; 796 } 797 setOpenWithDefaultFileManager(bool open)798 void setOpenWithDefaultFileManager(bool open) { 799 openWithDefaultFileManager_ = open; 800 } 801 allSticky()802 bool allSticky() const { 803 return allSticky_; 804 } 805 setAllSticky(bool sticky)806 void setAllSticky(bool sticky) { 807 allSticky_ = sticky; 808 } 809 showThumbnails()810 bool showThumbnails() { 811 return showThumbnails_; 812 } 813 setShowThumbnails(bool show)814 void setShowThumbnails(bool show) { 815 showThumbnails_ = show; 816 } 817 setThumbnailLocalFilesOnly(bool value)818 void setThumbnailLocalFilesOnly(bool value) { 819 Fm::ThumbnailJob::setLocalFilesOnly(value); 820 } 821 thumbnailLocalFilesOnly()822 bool thumbnailLocalFilesOnly() const { 823 return Fm::ThumbnailJob::localFilesOnly(); 824 } 825 maxThumbnailFileSize()826 int maxThumbnailFileSize() const { 827 return Fm::ThumbnailJob::maxThumbnailFileSize(); 828 } 829 setMaxThumbnailFileSize(int size)830 void setMaxThumbnailFileSize(int size) { 831 Fm::ThumbnailJob::setMaxThumbnailFileSize(size); 832 } 833 maxExternalThumbnailFileSize()834 int maxExternalThumbnailFileSize() const { 835 return Fm::ThumbnailJob::maxExternalThumbnailFileSize(); 836 } 837 setMaxExternalThumbnailFileSize(int size)838 void setMaxExternalThumbnailFileSize(int size) { 839 Fm::ThumbnailJob::setMaxExternalThumbnailFileSize(size); 840 } 841 setThumbnailIconSize(int thumbnailIconSize)842 void setThumbnailIconSize(int thumbnailIconSize) { 843 thumbnailIconSize_ = thumbnailIconSize; 844 } 845 siUnit()846 bool siUnit() { 847 return siUnit_; 848 } 849 setSiUnit(bool siUnit)850 void setSiUnit(bool siUnit) { 851 siUnit_ = siUnit; 852 // override libfm FmConfig settings. FIXME: should we do this? 853 fm_config->si_unit = (gboolean)siUnit_; 854 } 855 backupAsHidden()856 bool backupAsHidden() const { 857 return backupAsHidden_; 858 } 859 setBackupAsHidden(bool value)860 void setBackupAsHidden(bool value) { 861 backupAsHidden_ = value; 862 fm_config->backup_as_hidden = backupAsHidden_; // also set this to libfm since fm_file_info_is_hidden() reads this value internally. 863 } 864 showFullNames()865 bool showFullNames() const { 866 return showFullNames_; 867 } 868 setShowFullNames(bool value)869 void setShowFullNames(bool value) { 870 showFullNames_ = value; 871 } 872 shadowHidden()873 bool shadowHidden() const { 874 return shadowHidden_; 875 } 876 setShadowHidden(bool value)877 void setShadowHidden(bool value) { 878 shadowHidden_ = value; 879 } 880 noItemTooltip()881 bool noItemTooltip() const { 882 return noItemTooltip_; 883 } 884 setNoItemTooltip(bool noTooltip)885 void setNoItemTooltip(bool noTooltip) { 886 noItemTooltip_ = noTooltip; 887 } 888 scrollPerPixel()889 bool scrollPerPixel() const { 890 return scrollPerPixel_; 891 } 892 setScrollPerPixel(bool perPixel)893 void setScrollPerPixel(bool perPixel) { 894 scrollPerPixel_ = perPixel; 895 } 896 onlyUserTemplates()897 bool onlyUserTemplates() const { 898 return onlyUserTemplates_; 899 } 900 setOnlyUserTemplates(bool value)901 void setOnlyUserTemplates(bool value) { 902 onlyUserTemplates_ = value; 903 fm_config->only_user_templates = onlyUserTemplates_; 904 } 905 templateTypeOnce()906 bool templateTypeOnce() const { 907 return templateTypeOnce_; 908 } 909 setTemplateTypeOnce(bool value)910 void setTemplateTypeOnce(bool value) { 911 templateTypeOnce_ = value; 912 fm_config->template_type_once = templateTypeOnce_; 913 } 914 templateRunApp()915 bool templateRunApp() const { 916 return templateRunApp_; 917 } 918 setTemplateRunApp(bool value)919 void setTemplateRunApp(bool value) { 920 templateRunApp_ = value; 921 fm_config->template_run_app = templateRunApp_; 922 } 923 924 // per-folder settings 925 FolderSettings loadFolderSettings(const Fm::FilePath& path) const; 926 927 void saveFolderSettings(const Fm::FilePath& path, const FolderSettings& settings); 928 929 void clearFolderSettings(const Fm::FilePath& path) const; 930 searchNameCaseInsensitive()931 bool searchNameCaseInsensitive() const { 932 return searchNameCaseInsensitive_; 933 } 934 setSearchNameCaseInsensitive(bool caseInsensitive)935 void setSearchNameCaseInsensitive(bool caseInsensitive) { 936 searchNameCaseInsensitive_ = caseInsensitive; 937 } 938 searchContentCaseInsensitive()939 bool searchContentCaseInsensitive() const { 940 return searchContentCaseInsensitive_; 941 } 942 setsearchContentCaseInsensitive(bool caseInsensitive)943 void setsearchContentCaseInsensitive(bool caseInsensitive) { 944 searchContentCaseInsensitive_ = caseInsensitive; 945 } 946 searchNameRegexp()947 bool searchNameRegexp() const { 948 return searchNameRegexp_; 949 } 950 setSearchNameRegexp(bool reg)951 void setSearchNameRegexp(bool reg) { 952 searchNameRegexp_ = reg; 953 } 954 searchContentRegexp()955 bool searchContentRegexp() const { 956 return searchContentRegexp_; 957 } 958 setSearchContentRegexp(bool reg)959 void setSearchContentRegexp(bool reg) { 960 searchContentRegexp_ = reg; 961 } 962 searchRecursive()963 bool searchRecursive() const { 964 return searchRecursive_; 965 } 966 setSearchRecursive(bool rec)967 void setSearchRecursive(bool rec) { 968 searchRecursive_ = rec; 969 } 970 searchhHidden()971 bool searchhHidden() const { 972 return searchhHidden_; 973 } 974 setSearchhHidden(bool hidden)975 void setSearchhHidden(bool hidden) { 976 searchhHidden_ = hidden; 977 } 978 getCustomColumnWidths()979 QList<int> getCustomColumnWidths() const { 980 QList<int> l; 981 for(auto width : qAsConst(customColumnWidths_)) { 982 l << width.toInt(); 983 } 984 return l; 985 } 986 setCustomColumnWidths(const QList<int> & widths)987 void setCustomColumnWidths(const QList<int> &widths) { 988 customColumnWidths_.clear(); 989 for(auto width : widths) { 990 customColumnWidths_ << QVariant(width); 991 } 992 } 993 getHiddenColumns()994 QList<int> getHiddenColumns() const { 995 QList<int> l; 996 for(auto width : qAsConst(hiddenColumns_)) { 997 l << width.toInt(); 998 } 999 return l; 1000 } 1001 setHiddenColumns(const QList<int> & columns)1002 void setHiddenColumns(const QList<int> &columns) { 1003 hiddenColumns_.clear(); 1004 for(auto column : columns) { 1005 hiddenColumns_ << QVariant(column); 1006 } 1007 } 1008 1009 private: 1010 int toIconSize(int size, IconType type) const; 1011 1012 QString profileName_; 1013 bool supportTrash_; 1014 1015 // PCManFM specific 1016 QString fallbackIconThemeName_; 1017 bool useFallbackIconTheme_; 1018 1019 bool singleWindowMode_; 1020 OpenDirTargetType bookmarkOpenMethod_; 1021 QString suCommand_; 1022 QString terminal_; 1023 bool mountOnStartup_; 1024 bool mountRemovable_; 1025 bool autoRun_; 1026 bool closeOnUnmount_; 1027 1028 int wallpaperMode_; 1029 QString wallpaper_; 1030 QSize wallpaperDialogSize_; 1031 int wallpaperDialogSplitterPos_; 1032 QString lastSlide_; 1033 QString wallpaperDir_; 1034 int slideShowInterval_; 1035 bool wallpaperRandomize_; 1036 bool transformWallpaper_; 1037 bool perScreenWallpaper_; 1038 QColor desktopBgColor_; 1039 QColor desktopFgColor_; 1040 QColor desktopShadowColor_; 1041 QFont desktopFont_; 1042 int desktopIconSize_; 1043 QStringList desktopShortcuts_; 1044 1045 bool desktopShowHidden_; 1046 bool desktopHideItems_; 1047 Qt::SortOrder desktopSortOrder_; 1048 Fm::FolderModel::ColumnId desktopSortColumn_; 1049 bool desktopSortFolderFirst_; 1050 bool desktopSortHiddenLast_; 1051 1052 bool alwaysShowTabs_; 1053 bool showTabClose_; 1054 bool switchToNewTab_; 1055 bool reopenLastTabs_; 1056 QStringList tabPaths_; 1057 bool rememberWindowSize_; 1058 int fixedWindowWidth_; 1059 int fixedWindowHeight_; 1060 int lastWindowWidth_; 1061 int lastWindowHeight_; 1062 bool lastWindowMaximized_; 1063 int splitterPos_; 1064 bool sidePaneVisible_; 1065 Fm::SidePane::Mode sidePaneMode_; 1066 bool showMenuBar_; 1067 bool splitView_; 1068 1069 Fm::FolderView::ViewMode viewMode_; 1070 bool showHidden_; 1071 Qt::SortOrder sortOrder_; 1072 Fm::FolderModel::ColumnId sortColumn_; 1073 bool sortFolderFirst_; 1074 bool sortHiddenLast_; 1075 bool sortCaseSensitive_; 1076 bool showFilter_; 1077 bool pathBarButtons_; 1078 1079 // settings for use with libfm 1080 bool singleClick_; 1081 int autoSelectionDelay_; 1082 bool ctrlRightClick_; 1083 bool useTrash_; 1084 bool confirmDelete_; 1085 bool noUsbTrash_; // do not trash files on usb removable devices 1086 bool confirmTrash_; // Confirm before moving files into "trash can" 1087 bool quickExec_; // Don't ask options on launch executable file 1088 bool selectNewFiles_; 1089 1090 bool showThumbnails_; 1091 1092 QString archiver_; 1093 bool siUnit_; 1094 bool backupAsHidden_; 1095 bool showFullNames_; 1096 bool shadowHidden_; 1097 bool noItemTooltip_; 1098 bool scrollPerPixel_; 1099 1100 QSet<QString> hiddenPlaces_; 1101 1102 int bigIconSize_; 1103 int smallIconSize_; 1104 int sidePaneIconSize_; 1105 int thumbnailIconSize_; 1106 1107 bool onlyUserTemplates_; 1108 bool templateTypeOnce_; 1109 bool templateRunApp_; 1110 1111 QSize folderViewCellMargins_; 1112 QSize desktopCellMargins_; 1113 1114 bool openWithDefaultFileManager_; 1115 1116 bool allSticky_; 1117 1118 // search settings 1119 bool searchNameCaseInsensitive_; 1120 bool searchContentCaseInsensitive_; 1121 bool searchNameRegexp_; 1122 bool searchContentRegexp_; 1123 bool searchRecursive_; 1124 bool searchhHidden_; 1125 1126 // detailed list columns 1127 QList<QVariant> customColumnWidths_; 1128 QList<QVariant> hiddenColumns_; 1129 }; 1130 1131 } 1132 1133 #endif // PCMANFM_SETTINGS_H 1134