a23c48b468a2b946e8f17f6e2413658213d262af
[cuteexplorer] / src / mainwindow.cpp
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3
4 MainWindow::MainWindow(QWidget *parent) :
5     QMainWindow(parent),
6     ui(new Ui::MainWindow)
7 {
8     ui->setupUi(this);
9     connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
10     connect(ui->upButton, SIGNAL(clicked()), ui->fileListWidget, SLOT(changePathUp()));
11     connect(ui->locationLine, SIGNAL(returnPressed()), this, SLOT(locationLineEnterKeyHandler()));
12     connect(ui->fileListWidget, SIGNAL(pathChanged(QString)), ui->locationLine, SLOT(setText(QString)));
13     connect(ui->actionDelete, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionDelete()));
14     connect(ui->actionMode, SIGNAL(toggled(bool)), ui->fileListWidget, SLOT(actionSwitchMode(bool)));
15     connect(ui->actionCopy, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionCopy()));
16     connect(ui->actionCut, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionCut()));
17     connect(ui->actionPaste, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionPaste()));
18     connect(ui->actionShow_hidden, SIGNAL(toggled(bool)), ui->fileListWidget, SLOT(actionShowHidden(bool)));
19     connect(ui->actionRename, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionRename()));
20     connect(ui->actionSend, SIGNAL(triggered()), ui->fileListWidget, SLOT(actionSendFiles()));
21     ui->locationLine->setText(ui->fileListWidget->getPath());
22
23
24     ui->fileListWidget->addAction(ui->actionCopy);
25     ui->fileListWidget->addAction(ui->actionCut);
26     ui->fileListWidget->addAction(ui->actionPaste);
27     ui->fileListWidget->addAction(ui->actionDelete);
28     ui->fileListWidget->addAction(ui->actionRename);
29     ui->fileListWidget->addAction(ui->actionSend);
30 }
31
32 MainWindow::~MainWindow()
33 {
34     delete ui;
35 }
36
37 void MainWindow::locationLineEnterKeyHandler()
38 {
39     ui->fileListWidget->changePath(ui->locationLine->text());
40 }
41 void MainWindow::keyPressEvent(QKeyEvent *e)
42 {
43     if(e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift)
44         ui->fileListWidget->setSelectMode(true);
45     else
46         QMainWindow::keyPressEvent(e);
47 }
48 void MainWindow::keyReleaseEvent(QKeyEvent *e)
49 {
50     if(e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift)
51         ui->fileListWidget->setSelectMode(false);
52     else
53         QMainWindow::keyPressEvent(e);
54 }
55
56 void MainWindow::changeEvent(QEvent *e)
57 {
58     QMainWindow::changeEvent(e);
59     switch (e->type()) {
60     case QEvent::LanguageChange:
61         ui->retranslateUi(this);
62         break;
63     default:
64         break;
65     }
66 }
67