added icons for the buttons
[case] / src / case.cpp
index b3163ba..bac6bac 100644 (file)
@@ -1,5 +1,5 @@
 // case - file manager for N900
-// Copyright (C) 2010 Lukas Hrazky
+// Copyright (C) 2010 Lukas Hrazky <lukkash@email.cz>
 // 
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -27,11 +27,11 @@ Case::Case(QWidget *parent) :
     rightPane(new Pane(this)),
     activePane(leftPane),
     inactivePane(rightPane),
-    cloneBtn(new Button(">>", 0, 60, 70)),
-    moveBtn(new Button("mv>", 0, 60, 70)),
-    copyBtn(new Button("cp>", 0, 60, 70)),
-    delBtn(new Button("rm", 0, 60, 70)),
-    swapBtn(new Button("<>", 0, 60, 70)),
+    cloneBtn(new Button("clone", 0, 60, 70)),
+    swapBtn(new Button("swap", 0, 60, 70)),
+    copyBtn(new Button("copy", 0, 60, 70)),
+    moveBtn(new Button("move", 0, 60, 70)),
+    delBtn(new Button("delete", 0, 60, 70)),
     fileOperator(new FileOperator(this))
 {
     QVBoxLayout *layout = new QVBoxLayout;
@@ -58,10 +58,10 @@ Case::Case(QWidget *parent) :
     cloneBtn->setContentsMargins(0, 0, 0, 0);
 
     middleButtons->addWidget(cloneBtn);
-    middleButtons->addWidget(moveBtn);
+    middleButtons->addWidget(swapBtn);
     middleButtons->addWidget(copyBtn);
+    middleButtons->addWidget(moveBtn);
     middleButtons->addWidget(delBtn);
-    middleButtons->addWidget(swapBtn);
 
     paneLayout->addWidget(rightPane);
 
@@ -71,10 +71,10 @@ Case::Case(QWidget *parent) :
     connect(this, SIGNAL(activePaneSwitched()), rightPane, SLOT(toggleActive()));
 
     connect(cloneBtn, SIGNAL(pressed()), this, SLOT(clonePane()));
-    connect(delBtn, SIGNAL(pressed()), this, SLOT(deleteFiles()));
+    connect(swapBtn, SIGNAL(pressed()), this, SLOT(swapPanes()));
     connect(copyBtn, SIGNAL(pressed()), this, SLOT(copyFiles()));
     connect(moveBtn, SIGNAL(pressed()), this, SLOT(moveFiles()));
-    connect(swapBtn, SIGNAL(pressed()), this, SLOT(swapPanes()));
+    connect(delBtn, SIGNAL(pressed()), this, SLOT(deleteFiles()));
 }
 
 
@@ -83,27 +83,37 @@ void Case::switchActivePane() {
     activePane = inactivePane;
     inactivePane = tmpPane;
 
-    if (leftPane == activePane) {
-        cloneBtn->setText(">>");
-        moveBtn->setText("mv>");
-        copyBtn->setText("cp>");
-    } else {
-        cloneBtn->setText("<<");
-        moveBtn->setText("<mv");
-        copyBtn->setText("<cp");
-    }
+    cloneBtn->swapIcon();
+    swapBtn->swapIcon();
+    copyBtn->swapIcon();
+    moveBtn->swapIcon();
+    delBtn->swapIcon();
 
     emit activePaneSwitched();
 }
 
 
-void Case::deleteFiles() {
-    if (activePane->selection().size()) {
-        fileOperator->deleteFiles(activePane->selection());
+void Case::keyPressEvent(QKeyEvent *e) {
+    if(e->key() == Qt::Key_H && e->modifiers() == Qt::ControlModifier) {
+        activePane->toggleShowHiddenFiles();
+    } else {
+        QMainWindow::keyPressEvent(e);
     }
 }
 
 
+void Case::clonePane() {
+    inactivePane->changePath(activePane->path());
+}
+
+
+void Case::swapPanes() {
+    QString tmpPath = activePane->path();
+    activePane->changePath(inactivePane->path());
+    inactivePane->changePath(tmpPath);
+}
+
+
 void Case::copyFiles() {
     if (activePane->selection().size()) {
         QDir dest = inactivePane->path();
@@ -120,13 +130,8 @@ void Case::moveFiles() {
 }
 
 
-void Case::clonePane() {
-    inactivePane->changePath(activePane->path());
-}
-
-
-void Case::swapPanes() {
-    QString tmpPath = activePane->path();
-    activePane->changePath(inactivePane->path());
-    inactivePane->changePath(tmpPath);
+void Case::deleteFiles() {
+    if (activePane->selection().size()) {
+        fileOperator->deleteFiles(activePane->selection());
+    }
 }