summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/instancemodel.cpp2
-rw-r--r--gui/mainwindow.cpp36
-rw-r--r--gui/mainwindow.h3
3 files changed, 38 insertions, 3 deletions
diff --git a/gui/instancemodel.cpp b/gui/instancemodel.cpp
index dbeba0da..3cbb0fb9 100644
--- a/gui/instancemodel.cpp
+++ b/gui/instancemodel.cpp
@@ -68,7 +68,7 @@ QVariant InstanceModel::data ( const QModelIndex& index, int role ) const
}
case Qt::ToolTipRole:
{
- return pdata->rootDir();
+ return pdata->instanceRoot();
}
case Qt::DecorationRole:
{
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 6187de93..6176c079 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -109,6 +109,7 @@ MainWindow::MainWindow ( QWidget *parent ) :
view->setItemDelegate(delegate);
view->setSpacing(10);
view->setUniformItemWidths(true);
+ view->installEventFilter(this);
model = new InstanceModel ( instList,this );
proxymodel = new InstanceProxyModel ( this );
@@ -160,6 +161,37 @@ MainWindow::~MainWindow()
delete assets_downloader;
}
+bool MainWindow::eventFilter ( QObject* obj, QEvent* ev )
+{
+ if(obj == view)
+ {
+ if (ev->type() == QEvent::KeyPress)
+ {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
+ switch(keyEvent->key())
+ {
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ on_actionLaunchInstance_triggered();
+ return true;
+ case Qt::Key_Delete:
+ on_actionDeleteInstance_triggered();
+ return true;
+ case Qt::Key_F5:
+ on_actionRefresh_triggered();
+ return true;
+ case Qt::Key_F2:
+ on_actionRenameInstance_triggered();
+ return true;
+ default:
+ break;
+ }
+ }
+ }
+ return QMainWindow::eventFilter ( obj, ev );
+}
+
+
void MainWindow::instanceActivated ( QModelIndex index )
{
if(!index.isValid())
@@ -306,7 +338,7 @@ void MainWindow::on_actionDeleteInstance_triggered()
QString("This is permanent! Are you sure?\nAbout to delete: ") + inst->name());
if (response == QMessageBox::Yes)
{
- QDir(inst->rootDir()).removeRecursively();
+ QDir(inst->instanceRoot()).removeRecursively();
instList.loadList();
}
}
@@ -335,7 +367,7 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered()
BaseInstance* inst = selectedInstance();
if(inst)
{
- QString str = inst->rootDir();
+ QString str = inst->instanceRoot();
openDirInDefaultProgram ( QDir(str).absolutePath() );
}
}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index efcbc80c..62115e1d 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -122,6 +122,9 @@ public slots:
void launchInstance(BaseInstance *inst, LoginResponse response);
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
private:
Ui::MainWindow *ui;
KCategoryDrawer * drawer;