summaryrefslogtreecommitdiffstats
path: root/gui/mainwindow.cpp
diff options
context:
space:
mode:
authorOrochimarufan <orochimarufan.x3@gmail.com>2013-03-22 14:01:54 +0100
committerOrochimarufan <orochimarufan.x3@gmail.com>2013-03-22 14:01:54 +0100
commitcd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e (patch)
treea4148d6bb1704e635807c37b36013e9a33820a80 /gui/mainwindow.cpp
parentf4c9cb8c1d395422b7e4f1c27ac92b6df08a39bb (diff)
parente4806ab08d0293d395c1718ab16d28ba2ae9d0ed (diff)
downloadMultiMC-cd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e.tar
MultiMC-cd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e.tar.gz
MultiMC-cd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e.tar.lz
MultiMC-cd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e.tar.xz
MultiMC-cd1fdbbbc2953c5e34d8c0ae6861bec4a7f6532e.zip
Merge branch 'master' of http://github.com/peterix/MultiMC5
Conflicts: CMakeLists.txt main.cpp
Diffstat (limited to 'gui/mainwindow.cpp')
-rw-r--r--gui/mainwindow.cpp65
1 files changed, 58 insertions, 7 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index e691c8c4..5a915e8c 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -64,11 +64,25 @@ MainWindow::MainWindow ( QWidget *parent ) :
{
ui->setupUi ( this );
// Create the widget
- instList.loadList();
-
view = new KCategorizedView ( ui->centralWidget );
drawer = new KCategoryDrawer ( view );
-
+ /*
+ QPalette pal = view->palette();
+ pal.setBrush(QPalette::Base, QBrush(QPixmap(QString::fromUtf8(":/backgrounds/kitteh"))));
+ view->setPalette(pal);
+ */
+
+ view->setStyleSheet(
+ "QListView\
+ {\
+ background-image: url(:/backgrounds/kitteh);\
+ background-attachment: fixed;\
+ background-clip: padding;\
+ background-position: top right;\
+ background-repeat: none;\
+ background-color:palette(base);\
+ }");
+
view->setSelectionMode ( QAbstractItemView::SingleSelection );
//view->setSpacing( KDialog::spacingHint() );
view->setCategoryDrawer ( drawer );
@@ -100,7 +114,14 @@ MainWindow::MainWindow ( QWidget *parent ) :
view->setModel ( proxymodel );
connect(view, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(instanceActivated(const QModelIndex &)));
-
+
+ // Load the instances.
+ instList.loadList();
+ // just a test
+ /*
+ instList.at(0)->setGroup("TEST GROUP");
+ instList.at(0)->setName("TEST ITEM");
+ */
}
MainWindow::~MainWindow()
@@ -125,6 +146,18 @@ void MainWindow::on_actionAddInstance_triggered()
newInstDlg->exec();
}
+void MainWindow::on_actionChangeInstGroup_triggered()
+{
+ Instance* inst = selectedInstance();
+ if(inst)
+ {
+ QString name ( inst->group() );
+ name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ), QLineEdit::Normal, name );
+ inst->setGroup(name);
+ }
+}
+
+
void MainWindow::on_actionViewInstanceFolder_triggered()
{
openInDefaultProgram ( globalSettings->get ( "InstanceDir" ).toString() );
@@ -195,13 +228,31 @@ void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos
instContextMenu->exec ( view->mapToGlobal ( pos ) );
}
+Instance* MainWindow::selectedInstance()
+{
+ QAbstractItemView * iv = view;
+ auto smodel = iv->selectionModel();
+ QModelIndex mindex;
+ if(smodel->hasSelection())
+ {
+ auto rows = smodel->selectedRows();
+ mindex = rows.at(0);
+ }
+
+ if(mindex.isValid())
+ {
+ return (Instance *) mindex.data(InstanceModel::InstancePointerRole).value<void *>();
+ }
+ else
+ return nullptr;
+}
+
void MainWindow::on_actionLaunchInstance_triggered()
{
- QModelIndex index = view->currentIndex();
- if(index.isValid())
+ Instance* inst = selectedInstance();
+ if(inst)
{
- Instance * inst = (Instance *) index.data(InstanceModel::InstancePointerRole).value<void *>();
doLogin(inst->id());
}
}