mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Added IO list to NewFileDialog
This commit is contained in:
parent
b222aaa094
commit
ecb5fc75cf
@ -63,12 +63,10 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
ui->logoSvgWidget->load(Config()->getLogoFile());
|
||||
|
||||
fillRecentFilesList();
|
||||
fillIOPluginsList();
|
||||
|
||||
if (Config()->getNewFileLastClicked() == TAB_PROJECTS) {
|
||||
ui->tabWidget->setCurrentWidget(ui->projectsTab);
|
||||
} else {
|
||||
ui->tabWidget->setCurrentWidget(ui->filesTab);
|
||||
}
|
||||
// Set last clicked tab
|
||||
ui->tabWidget->setCurrentIndex(Config()->getNewFileLastClicked());
|
||||
|
||||
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
|
||||
|
||||
@ -306,9 +304,24 @@ bool NewFileDialog::fillProjectsList()
|
||||
return !projects.isEmpty();
|
||||
}
|
||||
|
||||
void NewFileDialog::fillIOPluginsList()
|
||||
{
|
||||
ui->ioPlugin->clear();
|
||||
ui->ioPlugin->addItem("");
|
||||
ui->ioPlugin->setItemData(0, tr("Open a file with no extra treatment."), Qt::ToolTipRole);
|
||||
|
||||
int index = 1;
|
||||
QList<RIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();
|
||||
for (RIOPluginDescription plugin : ioPlugins) {
|
||||
ui->ioPlugin->addItem(plugin.name);
|
||||
ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void NewFileDialog::loadFile(const QString &filename)
|
||||
{
|
||||
if (!ui->checkBox_FilelessOpen->isChecked() && !Core()->tryFile(filename, false)) {
|
||||
if (ui->ioPlugin->currentIndex() == 0 && !Core()->tryFile(filename, false) && !ui->checkBox_FilelessOpen->isChecked()) {
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText(tr("Select a new program or a previous one before continuing."));
|
||||
msgBox.exec();
|
||||
@ -327,7 +340,8 @@ void NewFileDialog::loadFile(const QString &filename)
|
||||
|
||||
// Close dialog and open MainWindow/OptionsDialog
|
||||
MainWindow *main = new MainWindow();
|
||||
main->openNewFile(filename);
|
||||
QString ioFile = ui->ioPlugin->currentText() + "://" + filename;
|
||||
main->openNewFile(ioFile);
|
||||
|
||||
close();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ class NewFileDialog : public QDialog
|
||||
public:
|
||||
explicit NewFileDialog(QWidget *parent = nullptr);
|
||||
~NewFileDialog();
|
||||
enum newFileTabs { TAB_FILES = 0, TAB_PROJECTS };
|
||||
|
||||
private slots:
|
||||
void on_loadFileButton_clicked();
|
||||
@ -55,6 +54,7 @@ private:
|
||||
* @return true if list is not empty
|
||||
*/
|
||||
bool fillProjectsList();
|
||||
void fillIOPluginsList();
|
||||
|
||||
void loadFile(const QString &filename);
|
||||
void loadProject(const QString &project);
|
||||
|
@ -151,7 +151,7 @@
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="selectFileButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -164,7 +164,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="newFileEdit">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
@ -174,7 +174,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="newFileLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
@ -183,7 +183,24 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">Select new file</span></p></body></html></string>
|
||||
<string><b>Select new file<b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="ioPlugin"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="ioLabel">
|
||||
<property name="text">
|
||||
<string><b>IO</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>://</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user