Changeset 763f65e


Ignore:
Timestamp:
06/27/14 08:00:46 (12 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, enter/10, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
f100def9
Parents:
b319b8cf
Message:

Fix up a bunch of little annoyances in lumina-fm:
1) Remove the tab selection of the shortcut buttons (Use the keyboard shortcuts for those instead), now it should only cycle between the dir contents and the dir path edit when the user hits tab.
2) Fix a random bug where the filesystem model is not sending out the "finished loading" signal. Put a manual 1.5 second timer in that will trigger the gui update if necessary.
3) Fix up the selection of the top item in the directory when changing directories (it mostly works, still have a couple random times where it will select something far down in the contents - no pattern detected yet though)
4) Make sure that the directory contents widget keeps keyboard focus when changing directories (if it had focus to begin with).
5) Remove the "edit" menu. The only thin in there was the preferences item (which does not exist yet since I have not found anything to put into user preferences).

Location:
lumina/lumina-fm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-fm/MainUI.cpp

    r92c92a5 r763f65e  
    1818    tabBar->setMovable(true); //tabs are independant - so allow the user to sort them 
    1919    tabBar->setShape(QTabBar::RoundedNorth); 
     20    tabBar->setFocusPolicy(Qt::NoFocus); 
    2021    ui->verticalLayout_browser->insertWidget(0,tabBar); 
    2122  currentDir = new QLineEdit(this); 
    2223    ui->toolBar->insertWidget(ui->actionBookMark, currentDir); 
     24    currentDir->setFocusPolicy(Qt::StrongFocus); 
    2325  fsmod = new QFileSystemModel(this); 
    2426    ui->tree_dir_view->setModel(fsmod); 
     
    3638    ui->tree_zfs_dir->sortByColumn(0, Qt::AscendingOrder); 
    3739  contextMenu = new QMenu(this); 
     40  upTimer = new QTimer(this); 
     41    upTimer->setSingleShot(true); 
     42    upTimer->setInterval(1500); // 1.5 second before manual update 
    3843  //Setup any specialty keyboard shortcuts 
    3944  nextTabLShort = new QShortcut( QKeySequence(tr("Shift+Left")), this); 
     
    7883  ui->actionClose->setIcon( LXDG::findIcon("application-exit","") ); 
    7984  ui->actionNew_Tab->setIcon( LXDG::findIcon("tab-new-background","") ); 
    80   ui->action_Preferences->setIcon( LXDG::findIcon("configure","") ); 
     85  //ui->action_Preferences->setIcon( LXDG::findIcon("configure","") ); 
    8186  ui->actionUpDir->setIcon( LXDG::findIcon("go-up","") ); 
    8287  ui->actionBack->setIcon( LXDG::findIcon("go-previous","") ); 
     
    118123  connect(ui->tree_dir_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(ItemRun(const QModelIndex &)) ); 
    119124  connect(fsmod, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded()) ); 
     125  connect(fsmod, SIGNAL(rootPathChanged(QString)), this, SLOT(directoryLoading()) ); 
     126  connect(upTimer, SIGNAL(timeout()), this, SLOT(directoryLoaded()) ); //manual check 
    120127         
    121128  //Page Switching 
     
    222229} 
    223230 
     231bool MainUI::checkUserPerms(){ 
     232  if(!isUserWritable){ 
     233    QMessageBox::warning(this, tr("Invalid Permissions"), tr("You do not have permission to edit this directory!") ); 
     234  } 
     235  return isUserWritable; 
     236} 
     237 
    224238QString MainUI::getCurrentDir(){ 
    225239  return currentDir->whatsThis(); 
     
    247261  //Update the directory viewer and update the line edit 
    248262  if(dir!=currentDir->whatsThis()){ 
     263    keepFocus = ui->tree_dir_view->hasFocus(); //the tree widget loses focus when the dir changes 
    249264    currentDir->setWhatsThis(dir); //save the full path internally 
    250     ui->tree_dir_view->setEnabled(false); //disable while loading 
    251     ui->label_dir_stats->setText(tr("Loading Directory...")); 
    252265    ui->tree_dir_view->setRootIndex( fsmod->setRootPath(dir) ); 
    253266  } 
     
    264277  QTimer::singleShot(0, this, SLOT(checkForBackups())); 
    265278  QTimer::singleShot(0, this, SLOT(checkForPictures())); 
    266   ui->tool_addToDir->setEnabled(isUserWritable); 
     279  ui->tool_addToDir->setVisible(isUserWritable); 
    267280  ui->actionUpDir->setEnabled(dir!="/"); 
    268281  ui->actionBack->setEnabled(history.length() > 1); 
     
    345358  //Disable all the UI elements specifically for the Browser side of things 
    346359  ui->actionNew_Tab->setEnabled(false); 
    347   ui->menuEdit->setEnabled(false); 
     360  //ui->menuEdit->setEnabled(false); 
    348361  ui->menuView->setEnabled(false); 
    349362  ui->menuBookmarks->setEnabled(false); 
     
    363376  //Disable all the UI elements specifically for the Browser side of things 
    364377  ui->actionNew_Tab->setEnabled(false); 
    365   ui->menuEdit->setEnabled(false); 
     378  //ui->menuEdit->setEnabled(false); 
    366379  ui->menuView->setEnabled(false); 
    367380  ui->menuBookmarks->setEnabled(false); 
     
    385398  //Disable all the UI elements specifically for the Browser side of things 
    386399  ui->actionNew_Tab->setEnabled(false); 
    387   ui->menuEdit->setEnabled(false); 
     400  //ui->menuEdit->setEnabled(false); 
    388401  ui->menuView->setEnabled(false); 
    389402  ui->menuBookmarks->setEnabled(false); 
     
    404417  //Disable all the UI elements specifically for the Browser side of things 
    405418  ui->actionNew_Tab->setEnabled(true); 
    406   ui->menuEdit->setEnabled(true); 
     419  //ui->menuEdit->setEnabled(true); 
    407420  ui->menuView->setEnabled(true); 
    408421  ui->menuBookmarks->setEnabled(true); 
     
    518531} 
    519532 
     533void MainUI::directoryLoading(){ 
     534  ui->tree_dir_view->setEnabled(false); //disable while loading 
     535  ui->label_dir_stats->setText(tr("Loading Directory...")); 
     536  upTimer->start(); 
     537} 
     538 
    520539void MainUI::directoryLoaded(){ 
     540  if(upTimer->isActive()){ upTimer->stop(); } 
    521541  ui->tree_dir_view->resizeColumnToContents(0); 
    522542  ui->tree_dir_view->setEnabled(true); //re-enable since it is done loading 
     
    524544        if(!isUserWritable){ msg = tr("Read-only directory"); } 
    525545  ui->label_dir_stats->setText(msg); 
     546  if(keepFocus){  
     547    ui->tree_dir_view->setFocus(Qt::OtherFocusReason);  
     548    //Make sure the top item is the one currently active 
     549    QModelIndex ind = ui->tree_dir_view->indexBelow( ui->tree_dir_view->rootIndex()); 
     550    //qDebug() << "Index:" << fsmod->filePath(ind) << ind.row(); 
     551    ui->tree_dir_view->setCurrentIndex( ind ); 
     552    keepFocus=false; //just in case the dir auto-loads later (don't want to reset selection!) 
     553  } 
    526554} 
    527555 
     
    606634  contextMenu->addAction(LXDG::findIcon("edit-cut",""), tr("Cut Selection"), this, SLOT(CutItems()) )->setEnabled(isUserWritable); 
    607635  contextMenu->addAction(LXDG::findIcon("edit-copy",""), tr("Copy Selection"), this, SLOT(CopyItems()) ); 
    608   contextMenu->addAction(LXDG::findIcon("edit-paste",""), tr("Paste"), this, SLOT(PasteItems()) )->setEnabled(QApplication::clipboard()->mimeData()->hasFormat("x-special/lumina-copied-files")); 
     636  contextMenu->addAction(LXDG::findIcon("edit-paste",""), tr("Paste"), this, SLOT(PasteItems()) )->setEnabled(QApplication::clipboard()->mimeData()->hasFormat("x-special/lumina-copied-files") && isUserWritable); 
    609637  contextMenu->addSeparator(); 
    610638  contextMenu->addAction(LXDG::findIcon("edit-delete",""), tr("Delete Selection"), this, SLOT(RemoveItem()) )->setEnabled(isUserWritable); 
     
    680708   sel.removeDuplicates(); 
    681709   if(sel.isEmpty()){ return; } //nothing selected 
     710   if(!checkUserPerms()){ return; } 
    682711   //Get the directories 
    683712   QString snapdir = snapDirs[ui->slider_zfs_snapshot->value()-1]; 
     
    727756  //Only let this run if viewing the browser page 
    728757  if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } 
    729    if(!isUserWritable){ 
    730      QMessageBox::warning(this, tr("Invalid Permissions"), tr("You do not have permission to edit the files in this directory!") ); 
    731      return; 
    732    } 
     758   if(!checkUserPerms()){ return; } 
    733759   //Get the selected items 
    734760   QStringList sel, names; 
     
    758784  if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } 
    759785  if(!CItem.isValid()){ return; } 
     786  if(!checkUserPerms()){ return; } 
    760787  QString fname = fsmod->filePath(CItem); 
    761788  QString path = fname; 
     
    792819  //Only let this run if viewing the browser page 
    793820  if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } 
     821  if(!checkUserPerms()){ return; } 
    794822  //Get all the selected Items  
    795823  QStringList sel; 
     
    843871  const QMimeData *dat = QApplication::clipboard()->mimeData(); 
    844872  if(!dat->hasFormat("x-special/lumina-copied-files")){ return; } //nothing to paste 
     873  if(!checkUserPerms()){ return; } 
    845874  QStringList cut, copy, newcut, newcopy; 
    846875  QStringList raw = QString(dat->data("x-special/lumina-copied-files")).split("\n"); 
  • lumina/lumina-fm/MainUI.h

    r92c92a5 r763f65e  
    6363        QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort, *copyFilesShort, *pasteFilesShort, *deleteFilesShort; 
    6464        QCompleter *dirCompleter; 
    65         bool isUserWritable; 
     65        bool isUserWritable, keepFocus; 
     66        QTimer *upTimer; 
    6667 
    6768        //Simplification Functions 
     
    7677        void RebuildBookmarksMenu(); 
    7778        void RebuildDeviceMenu(); 
     79         
     80        bool checkUserPerms(); 
    7881         
    7982        //Functions to get/set the currently active directory 
     
    115118        void startEditDir(QWidget *old, QWidget *now); 
    116119        void goToDirectory(); //go to a manually typed in directory 
    117         void directoryLoaded(); 
     120        void directoryLoading(); //fsmodel is loading directory 
     121        void directoryLoaded(); //fsmodel is done loading 
    118122        void on_tool_addToDir_clicked(); 
    119123        void tabChanged(int tab); 
  • lumina/lumina-fm/MainUI.ui

    r92c92a5 r763f65e  
    3030          <item> 
    3131           <widget class="QTreeView" name="tree_dir_view"> 
     32            <property name="focusPolicy"> 
     33             <enum>Qt::StrongFocus</enum> 
     34            </property> 
    3235            <property name="selectionMode"> 
    3336             <enum>QAbstractItemView::ExtendedSelection</enum> 
     
    6164            <item> 
    6265             <widget class="QToolButton" name="tool_addToDir"> 
     66              <property name="focusPolicy"> 
     67               <enum>Qt::NoFocus</enum> 
     68              </property> 
     69              <property name="statusTip"> 
     70               <string>Create a new subdirectory</string> 
     71              </property> 
    6372              <property name="text"> 
    6473               <string notr="true">&amp;New Dir</string> 
     
    8089            <item> 
    8190             <widget class="QToolButton" name="tool_goToPlayer"> 
     91              <property name="focusPolicy"> 
     92               <enum>Qt::NoFocus</enum> 
     93              </property> 
    8294              <property name="toolTip"> 
    8395               <string>Open Multimedia Player</string> 
    8496              </property> 
     97              <property name="statusTip"> 
     98               <string>Play any multimedia files in this directory</string> 
     99              </property> 
    85100              <property name="text"> 
    86101               <string>Play</string> 
     
    96111            <item> 
    97112             <widget class="QToolButton" name="tool_goToImages"> 
     113              <property name="focusPolicy"> 
     114               <enum>Qt::NoFocus</enum> 
     115              </property> 
    98116              <property name="toolTip"> 
    99117               <string>View Slideshow</string> 
    100118              </property> 
     119              <property name="statusTip"> 
     120               <string>View all the images in this directory as a slideshow</string> 
     121              </property> 
    101122              <property name="text"> 
    102123               <string>&amp;Slideshow</string> 
     
    115136            <item> 
    116137             <widget class="QToolButton" name="tool_goToRestore"> 
     138              <property name="focusPolicy"> 
     139               <enum>Qt::NoFocus</enum> 
     140              </property> 
    117141              <property name="toolTip"> 
    118142               <string>Restore File(s)</string> 
     143              </property> 
     144              <property name="statusTip"> 
     145               <string>Restore old versions of files or directories</string> 
    119146              </property> 
    120147              <property name="text"> 
     
    542569    <addaction name="separator"/> 
    543570    <addaction name="actionClose"/> 
    544    </widget> 
    545    <widget class="QMenu" name="menuEdit"> 
    546     <property name="title"> 
    547      <string>Edit</string> 
    548     </property> 
    549     <addaction name="action_Preferences"/> 
    550571   </widget> 
    551572   <widget class="QMenu" name="menuView"> 
     
    569590   </widget> 
    570591   <addaction name="menuFile"/> 
    571    <addaction name="menuEdit"/> 
    572592   <addaction name="menuView"/> 
    573593   <addaction name="menuBookmarks"/> 
     
    607627  <action name="actionClose"> 
    608628   <property name="text"> 
    609     <string>E&amp;xit</string> 
     629    <string>Exit</string> 
    610630   </property> 
    611631   <property name="shortcut"> 
    612632    <string>Ctrl+Q</string> 
     633   </property> 
     634   <property name="shortcutContext"> 
     635    <enum>Qt::ApplicationShortcut</enum> 
    613636   </property> 
    614637  </action> 
     
    694717  <action name="actionManage_Bookmarks"> 
    695718   <property name="enabled"> 
    696     <bool>false</bool> 
     719    <bool>true</bool> 
    697720   </property> 
    698721   <property name="text"> 
Note: See TracChangeset for help on using the changeset viewer.