Add/remove/drag&drop for the icon picker.
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
#include "instancedelegate.h"
|
||||
#include "ui_IconPickerDialog.h"
|
||||
#include "logic/IconListModel.h"
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@ -25,9 +28,24 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
||||
contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
contentsWidget->setItemDelegate(new ListViewDelegate());
|
||||
|
||||
//contentsWidget->setAcceptDrops(true);
|
||||
contentsWidget->setDropIndicatorShown(true);
|
||||
contentsWidget->viewport()->setAcceptDrops(true);
|
||||
contentsWidget->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
contentsWidget->setDefaultDropAction(Qt::CopyAction);
|
||||
|
||||
contentsWidget->installEventFilter(this);
|
||||
|
||||
IconList * list = IconList::instance();
|
||||
contentsWidget->setModel(list);
|
||||
|
||||
auto buttonAdd = ui->buttonBox->addButton("Add Icon",QDialogButtonBox::ResetRole);
|
||||
auto buttonRemove = ui->buttonBox->addButton("Remove Icon",QDialogButtonBox::ResetRole);
|
||||
|
||||
|
||||
connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon()));
|
||||
connect(buttonRemove,SIGNAL(clicked(bool)),SLOT(removeSelectedIcon()));
|
||||
|
||||
connect
|
||||
(
|
||||
contentsWidget,
|
||||
@ -42,6 +60,43 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
||||
SLOT(selectionChanged(QItemSelection,QItemSelection))
|
||||
);
|
||||
}
|
||||
bool IconPickerDialog::eventFilter ( QObject* obj, QEvent* evt)
|
||||
{
|
||||
if(obj != ui->iconView)
|
||||
return QDialog::eventFilter(obj ,evt);
|
||||
if (evt->type() != QEvent::KeyPress)
|
||||
{
|
||||
return QDialog::eventFilter(obj ,evt);
|
||||
}
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(evt);
|
||||
IconList * list = IconList::instance();
|
||||
switch(keyEvent->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
removeSelectedIcon();
|
||||
return true;
|
||||
case Qt::Key_Plus:
|
||||
addNewIcon();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QDialog::eventFilter(obj ,evt);
|
||||
}
|
||||
|
||||
void IconPickerDialog::addNewIcon()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Icons", QString(), "Icons (*.png *.jpg *.jpeg)");
|
||||
IconList * list = IconList::instance();
|
||||
list->installIcons(fileNames);
|
||||
}
|
||||
|
||||
void IconPickerDialog::removeSelectedIcon()
|
||||
{
|
||||
IconList * list = IconList::instance();
|
||||
list->deleteIcon(selectedIconKey);
|
||||
}
|
||||
|
||||
|
||||
void IconPickerDialog::activated ( QModelIndex index )
|
||||
{
|
||||
|
@ -15,7 +15,8 @@ public:
|
||||
~IconPickerDialog();
|
||||
int exec(QString selection);
|
||||
QString selectedIconKey;
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter ( QObject* , QEvent* );
|
||||
private:
|
||||
Ui::IconPickerDialog *ui;
|
||||
|
||||
@ -23,4 +24,6 @@ private slots:
|
||||
void selectionChanged ( QItemSelection,QItemSelection );
|
||||
void activated ( QModelIndex );
|
||||
void delayed_scroll ( QModelIndex );
|
||||
void addNewIcon();
|
||||
void removeSelectedIcon();
|
||||
};
|
||||
|
@ -1,23 +1,24 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "ui_aboutdialog.h"
|
||||
#include <AppVersion.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QApplication>
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64));
|
||||
ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64));
|
||||
ui->title->setText("MultiMC " + AppVersion::current.toString());
|
||||
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
QApplication::instance()->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt()));
|
||||
QApplication::instance()->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt()));
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -42,13 +42,6 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="compatModeCheckBox">
|
||||
<property name="text">
|
||||
<string>Compatibility mode?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="maximizedCheckBox">
|
||||
<property name="text">
|
||||
@ -403,7 +396,6 @@
|
||||
<tabstops>
|
||||
<tabstop>settingsTabs</tabstop>
|
||||
<tabstop>windowSizeGroupBox</tabstop>
|
||||
<tabstop>compatModeCheckBox</tabstop>
|
||||
<tabstop>maximizedCheckBox</tabstop>
|
||||
<tabstop>windowWidthSpinBox</tabstop>
|
||||
<tabstop>windowHeightSpinBox</tabstop>
|
||||
|
@ -87,6 +87,7 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
||||
// the rename label is inside the rename tool button
|
||||
renameButton = new LabeledToolButton();
|
||||
renameButton->setText("Instance Name");
|
||||
renameButton->setToolTip(ui->actionRenameInstance->toolTip());
|
||||
connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
|
||||
ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
|
||||
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
||||
|
@ -43,12 +43,8 @@ void SettingsDialog::showEvent ( QShowEvent* ev )
|
||||
|
||||
void SettingsDialog::updateCheckboxStuff()
|
||||
{
|
||||
ui->windowWidthSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
ui->windowHeightSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
|
||||
ui->maximizedCheckBox->setEnabled(!ui->compatModeCheckBox->isChecked());
|
||||
ui->windowWidthSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
|
||||
ui->windowHeightSpinBox->setEnabled(! ui->maximizedCheckBox->isChecked());
|
||||
}
|
||||
|
||||
void SettingsDialog::on_instDirBrowseBtn_clicked()
|
||||
|
@ -54,6 +54,9 @@
|
||||
<property name="text">
|
||||
<string>By last launched</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">sortingModeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -61,6 +64,9 @@
|
||||
<property name="text">
|
||||
<string>By name</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">sortingModeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -175,13 +181,6 @@
|
||||
<string>Window Size</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="compatModeCheckBox">
|
||||
<property name="text">
|
||||
<string>Compatibility mode?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="maximizedCheckBox">
|
||||
<property name="text">
|
||||
@ -504,4 +503,7 @@
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="sortingModeGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
Reference in New Issue
Block a user