diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-06-23 22:10:32 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-06-23 22:10:32 +0200 |
commit | 27b1de0d6d196d9d0f6c284e0cb772c077688c3e (patch) | |
tree | daf8998763f549c28cac6be272fe50f70c00be0d /gui/mainwindow.cpp | |
parent | d9195bff3a6088bb0f116d61fc8c961e3ba4e3f2 (diff) | |
download | MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.gz MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.lz MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.tar.xz MultiMC-27b1de0d6d196d9d0f6c284e0cb772c077688c3e.zip |
Implement some bits and pieces, disable dead buttons.
Diffstat (limited to 'gui/mainwindow.cpp')
-rw-r--r-- | gui/mainwindow.cpp | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e60155c6..dda12941 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -64,7 +64,8 @@ // Opens the given file in the default application. // TODO: Move this somewhere. -void openInDefaultProgram ( QString filename ); +void openFileInDefaultProgram ( QString filename ); +void openDirInDefaultProgram ( QString dirpath, bool ensureExists = false ); MainWindow::MainWindow ( QWidget *parent ) : QMainWindow ( parent ), @@ -224,16 +225,22 @@ void MainWindow::on_actionChangeInstGroup_triggered() Instance* inst = selectedInstance(); if(inst) { + bool ok = false; QString name ( inst->group() ); - name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ), QLineEdit::Normal, name ); - inst->setGroup(name); + QInputDialog dlg(this); + dlg.result(); + name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ), + QLineEdit::Normal, name, &ok ); + if(ok) + inst->setGroup(name); } } void MainWindow::on_actionViewInstanceFolder_triggered() { - openInDefaultProgram ( globalSettings->get ( "InstanceDir" ).toString() ); + QString str = globalSettings->get ( "InstanceDir" ).toString(); + openDirInDefaultProgram ( str ); } void MainWindow::on_actionRefresh_triggered() @@ -243,7 +250,7 @@ void MainWindow::on_actionRefresh_triggered() void MainWindow::on_actionViewCentralModsFolder_triggered() { - openInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() ); + openDirInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() , true); } void MainWindow::on_actionCheckUpdate_triggered() @@ -282,6 +289,37 @@ void MainWindow::on_mainToolBar_visibilityChanged ( bool ) ui->mainToolBar->setVisible ( true ); } +void MainWindow::on_actionDeleteInstance_triggered() +{ + +} + +void MainWindow::on_actionRenameInstance_triggered() +{ + Instance* inst = selectedInstance(); + if(inst) + { + bool ok = false; + QString name ( inst->name() ); + name = QInputDialog::getText ( this, tr ( "Instance name" ), tr ( "Enter a new instance name." ), + QLineEdit::Normal, name, &ok ); + //FIXME: dialog should do the validation!!! + if(ok && name.length() && name.length() <= 25) + inst->setName(name); + } +} + +void MainWindow::on_actionViewSelectedInstFolder_triggered() +{ + Instance* inst = selectedInstance(); + if(inst) + { + QString str = inst->rootDir(); + openDirInDefaultProgram ( QDir(str).absolutePath() ); + } +} + + void MainWindow::closeEvent ( QCloseEvent *event ) { // Save the window state and geometry. @@ -449,7 +487,18 @@ void MainWindow::openWebPage ( QUrl url ) browser->exec(); } -void openInDefaultProgram ( QString filename ) +void openDirInDefaultProgram ( QString path, bool ensureExists ) +{ + QDir parentPath; + QDir dir( path ); + if(!dir.exists()) + { + parentPath.mkpath(dir.absolutePath()); + } + QDesktopServices::openUrl ( "file:///" + dir.absolutePath() ); +} + +void openFileInDefaultProgram ( QString filename ) { QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() ); } |