Initial commit
[cuteexplorer] / 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 MainWindow::~MainWindow()
25 {
26     delete ui;
27 }
28
29 void MainWindow::locationLineEnterKeyHandler()
30 {
31     ui->fileListWidget->changePath(ui->locationLine->text());
32 }
33 void MainWindow::keyPressEvent(QKeyEvent *e)
34 {
35     if(e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift)
36         ui->fileListWidget->setSelectMode(true);
37     else
38         QMainWindow::keyPressEvent(e);
39 }
40 void MainWindow::keyReleaseEvent(QKeyEvent *e)
41 {
42     if(e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift)
43         ui->fileListWidget->setSelectMode(false);
44     else
45         QMainWindow::keyPressEvent(e);
46 }
47
48 void MainWindow::changeEvent(QEvent *e)
49 {
50     QMainWindow::changeEvent(e);
51     switch (e->type()) {
52     case QEvent::LanguageChange:
53         ui->retranslateUi(this);
54         break;
55     default:
56         break;
57     }
58 }
59