diff options
author | Ken Moore <moorekou@gmail.com> | 2015-10-15 13:59:29 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-10-15 13:59:29 -0400 |
commit | dd2c75a495c451ca27ed8a3ac1c670509bad7fdc (patch) | |
tree | 4daa98484575dc8d2aee292663b570c6d9c7ccc8 /lumina-fm | |
parent | Add an option to lumina-fm to spawn a new instance/window (Ctrl-N keyboard sh... (diff) | |
download | lumina-dd2c75a495c451ca27ed8a3ac1c670509bad7fdc.tar.gz lumina-dd2c75a495c451ca27ed8a3ac1c670509bad7fdc.tar.bz2 lumina-dd2c75a495c451ca27ed8a3ac1c670509bad7fdc.zip |
Clean up the copy/cut/paste/delete keyboard shortcuts. Now the shortcuts are registered in the main window, and it passes the signal to the currently-active browser for evaluation/action. This allows the shortcuts to work no matter what window/widget is currently active.
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/MainUI.cpp | 38 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 7 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.cpp | 30 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.h | 8 |
4 files changed, 75 insertions, 8 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 8b367f39..b9f983be 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -91,7 +91,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ nextTabRShort = new QShortcut( QKeySequence(tr("Shift+Right")), this); closeTabShort = new QShortcut( QKeySequence(tr("Ctrl+W")), this); refreshShort = new QShortcut( QKeySequence(tr("F5")), this); - + copyFilesShort = new QShortcut( QKeySequence(tr("Ctrl+C")), this); + pasteFilesShort = new QShortcut( QKeySequence(tr("Ctrl+V")), this); + cutFilesShort = new QShortcut( QKeySequence(tr("Ctrl+X")), this); + deleteFilesShort = new QShortcut( QKeySequence(tr("Delete")), this); + //Finish loading the interface workThread->start(); if(DEBUG){ qDebug() << " - Icons"; } @@ -235,7 +239,10 @@ void MainUI::setupConnections(){ connect(nextTabRShort, SIGNAL(activated()), this, SLOT( nextTab() ) ); connect(closeTabShort, SIGNAL(activated()), this, SLOT( tabClosed() ) ); connect(refreshShort , SIGNAL(activated()), this, SLOT( refreshTabs() ) ); - + connect(copyFilesShort, SIGNAL(activated()), this, SLOT( CopyFilesTriggered() ) ); + connect(cutFilesShort, SIGNAL(activated()), this, SLOT( CutFilesTriggered() ) ); + connect(pasteFilesShort, SIGNAL(activated()), this, SLOT( PasteFilesTriggered() ) ); + connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( DeleteFilesTriggered() ) ); } @@ -343,7 +350,7 @@ DirWidget* MainUI::FindActiveBrowser(){ } }else{ //This is a bit more complex - either showing multiple columns or a non-browser tab is active - if(cur=="Browser"){ + if(cur=="browser"){ //Column View QWidget *focus = QApplication::focusWidget(); //the widget which currently has focus for(int i=0; i<DWLIST.length(); i++){ @@ -602,6 +609,31 @@ void MainUI::refreshTabs(){ if(cur!=0){ cur->refresh(); } } +//Special Keyboard shortcut interactions +void MainUI::CopyFilesTriggered(){ + DirWidget *dir = FindActiveBrowser(); + if(DEBUG){ qDebug() << "Copy Shortcut Pressed:" << dir << dir->currentDir(); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryCopySelection()) ); } +} + +void MainUI::CutFilesTriggered(){ + DirWidget *dir = FindActiveBrowser(); + if(DEBUG){ qDebug() << "Cut Shortcut Pressed:" << dir << dir->currentDir(); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryCutSelection()) ); } +} + +void MainUI::PasteFilesTriggered(){ + DirWidget *dir = FindActiveBrowser(); + if(DEBUG){ qDebug() << "Paste Shortcut Pressed:" << dir << dir->currentDir(); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryPasteSelection()) ); } +} + +void MainUI::DeleteFilesTriggered(){ + DirWidget *dir = FindActiveBrowser(); + if(DEBUG){ qDebug() << "Delete Shortcut Pressed:" << dir << dir->currentDir(); } + if(dir!=0){ QTimer::singleShot(0, dir, SLOT(TryDeleteSelection()) ); } +} + void MainUI::DirDataAvailable(QString id, QString dir, LFileInfoList list){ for(int i=0; i<DWLIST.length(); i++){ if(id == DWLIST[i]->id()){ diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 588e2f15..e9a2aff8 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -89,6 +89,7 @@ private: QSettings *settings; QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort, *refreshShort; + QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort; QCompleter *dirCompleter; //Simplification Functions @@ -132,6 +133,12 @@ private slots: void prevTab(); //For keyboard shortcuts void refreshTabs(); //For keyboard shortcut + //Special Keyboard shortcut interactions + void CopyFilesTriggered(); + void CutFilesTriggered(); + void PasteFilesTriggered(); + void DeleteFilesTriggered(); + //Backend Info passing void DirDataAvailable(QString, QString, LFileInfoList); void SnapshotDataAvailable(QString, QString, QStringList); diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index 21029fb5..2f172337 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -54,10 +54,10 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U ui->browser_layout->addWidget(listWidget); ui->browser_layout->addWidget(treeWidget); //Create the keyboard shortcuts - copyFilesShort = new QShortcut( QKeySequence(tr("Ctrl+C")), this); + /*copyFilesShort = new QShortcut( QKeySequence(tr("Ctrl+C")), this); pasteFilesShort = new QShortcut( QKeySequence(tr("Ctrl+V")), this); cutFilesShort = new QShortcut( QKeySequence(tr("Ctrl+X")), this); - deleteFilesShort = new QShortcut( QKeySequence(tr("Delete")), this); + deleteFilesShort = new QShortcut( QKeySequence(tr("Delete")), this);*/ //Create the filesystem watcher watcher = new QFileSystemWatcher(this); synctimer = new QTimer(this); @@ -555,6 +555,23 @@ void DirWidget::UpdateButtons(){ SelectionChanged(); } +//Keyboard Shortcuts triggered +void DirWidget::TryCutSelection(){ + on_tool_act_cut_clicked(); +} + +void DirWidget::TryCopySelection(){ + on_tool_act_copy_clicked(); +} + +void DirWidget::TryPasteSelection(){ + on_tool_act_paste_clicked(); +} + +void DirWidget::TryDeleteSelection(){ + on_tool_act_rm_clicked(); +} + // ================= // PRIVATE // ================= @@ -573,10 +590,10 @@ void DirWidget::setupConnections(){ connect(line_dir, SIGNAL(returnPressed()), this, SLOT(dir_changed()) ); //Keyboard Shortcuts - connect(copyFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_copy_clicked() ) ); + /*connect(copyFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_copy_clicked() ) ); connect(cutFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_cut_clicked() ) ); connect(pasteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_paste_clicked() ) ); - connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) ); + connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) );*/ //Filesystem Watcher connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(startSync(const QString &)) ); @@ -634,6 +651,7 @@ void DirWidget::startLoadThumbs(){ // -- Left Action Buttons void DirWidget::on_tool_act_cut_clicked(){ QStringList sel = currentSelection(); + qDebug() << "Cutting Items to clipboard:" << sel; if(sel.isEmpty()){ return; } emit CutFiles(sel); } @@ -641,16 +659,19 @@ void DirWidget::on_tool_act_cut_clicked(){ void DirWidget::on_tool_act_copy_clicked(){ QStringList sel = currentSelection(); if(sel.isEmpty()){ return; } + qDebug() << "Copying Items to clipboard:" << sel; emit CopyFiles(sel); } void DirWidget::on_tool_act_fav_clicked(){ QStringList sel = currentSelection(); if(sel.isEmpty()){ return; } + emit FavoriteFiles(sel); } void DirWidget::on_tool_act_paste_clicked(){ + qDebug() << "Pasting Items from clipboard:" << CDIR; emit PasteFiles(CDIR, QStringList()); //use the clipboard for pasting } @@ -663,6 +684,7 @@ void DirWidget::on_tool_act_rename_clicked(){ void DirWidget::on_tool_act_rm_clicked(){ QStringList sel = currentSelection(); if(sel.isEmpty()){ return; } + qDebug() << "Deleting selected Items:" << sel; emit RemoveFiles(sel); } diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index 274873e2..70936b97 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -71,6 +71,12 @@ public slots: //Button updates void UpdateButtons(); + //Keyboard Shortcuts triggered + void TryCutSelection(); + void TryCopySelection(); + void TryPasteSelection(); + void TryDeleteSelection(); + private: Ui::DirWidget *ui; QString ID, CDIR; //unique ID assigned by the parent and the current dir path @@ -90,7 +96,7 @@ private: DDTreeWidget *treeWidget; //Keyboard Shortcuts - QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort; + //QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort; //Watcher to determine when the dir changes QFileSystemWatcher *watcher; QTimer *synctimer; |