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 | |
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')
-rw-r--r-- | gui/mainwindow.cpp | 61 | ||||
-rw-r--r-- | gui/mainwindow.h | 9 | ||||
-rw-r--r-- | gui/mainwindow.ui | 25 | ||||
-rw-r--r-- | gui/taskdialog.h | 2 |
4 files changed, 85 insertions, 12 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() ); } diff --git a/gui/mainwindow.h b/gui/mainwindow.h index a9a4d395..b861cbe7 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -63,6 +63,8 @@ private slots: void on_actionChangeInstGroup_triggered(); void on_actionViewInstanceFolder_triggered(); + + void on_actionViewSelectedInstFolder_triggered(); void on_actionRefresh_triggered(); @@ -82,8 +84,11 @@ private slots: void on_actionLaunchInstance_triggered(); - - void on_actionMakeDesktopShortcut_triggered(); + void on_actionDeleteInstance_triggered(); + + void on_actionRenameInstance_triggered(); + + void on_actionMakeDesktopShortcut_triggered(); void on_actionChangeInstMCVersion_triggered(); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index fe6de6c9..44b8a31f 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>600</width> - <height>400</height> + <width>692</width> + <height>596</height> </rect> </property> <property name="windowTitle"> @@ -271,6 +271,9 @@ </property> </action> <action name="actionChangeInstIcon"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Change Icon</string> </property> @@ -282,6 +285,9 @@ </property> </action> <action name="actionEditInstNotes"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Edit Notes</string> </property> @@ -293,6 +299,9 @@ </property> </action> <action name="actionInstanceSettings"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Settings</string> </property> @@ -304,6 +313,9 @@ </property> </action> <action name="actionMakeDesktopShortcut"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Make Shortcut</string> </property> @@ -315,6 +327,9 @@ </property> </action> <action name="actionManageInstSaves"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Manage Saves</string> </property> @@ -326,6 +341,9 @@ </property> </action> <action name="actionEditInstMods"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Edit Mods</string> </property> @@ -359,6 +377,9 @@ </property> </action> <action name="actionRebuildInstJar"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Rebuild Jar</string> </property> diff --git a/gui/taskdialog.h b/gui/taskdialog.h index faf3ed90..86cd4b54 100644 --- a/gui/taskdialog.h +++ b/gui/taskdialog.h @@ -45,8 +45,6 @@ public slots: void changeStatus(const QString& status); void changeProgress(int progress); - void test() { qDebug("Lol"); } - signals: |