mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
Replace the file selection dialog for the mountpoint with a pure folder tree view. This fixes an issue with the selection dialog which could try opening a nonexisting folder. Only allow to select drive letters on windows. Additionally, remove an old file I forgot earlier.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14233 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
611c699fd7
commit
3a4e540c3d
6 changed files with 175 additions and 85 deletions
70
rbutil/rbutilqt/browsedirtree.cpp
Normal file
70
rbutil/rbutilqt/browsedirtree.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Riebeling
|
||||||
|
* $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include "browsedirtree.h"
|
||||||
|
#include "ui_browsedirtreefrm.h"
|
||||||
|
|
||||||
|
|
||||||
|
BrowseDirtree::BrowseDirtree(QWidget *parent) : QDialog(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
this->setModal(true);
|
||||||
|
ui.tree->setModel(&model);
|
||||||
|
model.setReadOnly(true);
|
||||||
|
// disable size / date / type columns
|
||||||
|
ui.tree->setColumnHidden(1, true);
|
||||||
|
ui.tree->setColumnHidden(2, true);
|
||||||
|
ui.tree->setColumnHidden(3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BrowseDirtree::setDir(QDir &dir)
|
||||||
|
{
|
||||||
|
qDebug() << "BrowseDirtree::setDir()" << model.index(dir.absolutePath());
|
||||||
|
|
||||||
|
// hilight the set directory if it's valid
|
||||||
|
if(model.index(dir.absolutePath()).isValid()) {
|
||||||
|
model.index(dir.absolutePath()).parent();
|
||||||
|
|
||||||
|
QModelIndex p = model.index(dir.absolutePath());
|
||||||
|
ui.tree->setCurrentIndex(p);
|
||||||
|
ui.tree->scrollTo(p);
|
||||||
|
ui.tree->resizeColumnToContents(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BrowseDirtree::setFilter(QDir::Filters filters)
|
||||||
|
{
|
||||||
|
model.setFilter(filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BrowseDirtree::accept()
|
||||||
|
{
|
||||||
|
QString path;
|
||||||
|
path = model.filePath(ui.tree->currentIndex());
|
||||||
|
|
||||||
|
this->close();
|
||||||
|
emit itemChanged(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
46
rbutil/rbutilqt/browsedirtree.h
Normal file
46
rbutil/rbutilqt/browsedirtree.h
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Riebeling
|
||||||
|
* $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BROWSEDIRTREE_H
|
||||||
|
#define BROWSEDIRTREE_H
|
||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
#include "ui_browsedirtreefrm.h"
|
||||||
|
|
||||||
|
class BrowseDirtree : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BrowseDirtree(QWidget *parent = 0);
|
||||||
|
void setFilter(QDir::Filters);
|
||||||
|
void setDir(QDir&);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void itemChanged(QString);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::BrowseDirtreeFrm ui;
|
||||||
|
QDirModel model;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void accept(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,68 +1,32 @@
|
||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
<class>InstallZipFrm</class>
|
<class>BrowseDirtreeFrm</class>
|
||||||
<widget class="QDialog" name="InstallZipFrm" >
|
<widget class="QDialog" name="BrowseDirtreeFrm" >
|
||||||
<property name="windowModality" >
|
|
||||||
<enum>Qt::WindowModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>275</width>
|
||||||
<height>450</height>
|
<height>380</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Install Zip</string>
|
<string>Find Directory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" >
|
||||||
<item rowspan="4" row="0" column="0" >
|
<item row="0" column="0" colspan="2" >
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string/>
|
<string>Browse to the destination folder</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap" >
|
<property name="wordWrap" >
|
||||||
<pixmap resource="rbutilqt.qrc" >:/icons/icons/wizard.xpm</pixmap>
|
<bool>true</bool>
|
||||||
</property>
|
|
||||||
<property name="alignment" >
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="4" >
|
<item row="1" column="0" colspan="2" >
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QTreeView" name="tree" />
|
||||||
<property name="text" >
|
|
||||||
<string>Select your device in the filesystem</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="3" >
|
<item row="2" column="0" >
|
||||||
<widget class="QLineEdit" name="lineMountPoint" />
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4" >
|
|
||||||
<widget class="QPushButton" name="buttonBrowse" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Browse</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/icons/system-search.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2" >
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" >
|
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
|
@ -75,7 +39,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3" colspan="2" >
|
<item row="2" column="1" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="buttonOk" >
|
<widget class="QPushButton" name="buttonOk" >
|
||||||
|
|
@ -106,34 +70,34 @@
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonOk</sender>
|
<sender>buttonCancel</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>InstallZipFrm</receiver>
|
<receiver>BrowseDirtreeFrm</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel" >
|
||||||
<x>472</x>
|
<x>224</x>
|
||||||
<y>418</y>
|
<y>355</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel" >
|
||||||
<x>382</x>
|
<x>48</x>
|
||||||
<y>328</y>
|
<y>349</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonCancel</sender>
|
<sender>buttonOk</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>InstallZipFrm</receiver>
|
<receiver>BrowseDirtreeFrm</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel" >
|
||||||
<x>561</x>
|
<x>146</x>
|
||||||
<y>428</y>
|
<y>358</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel" >
|
||||||
<x>522</x>
|
<x>74</x>
|
||||||
<y>332</y>
|
<y>357</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#include "autodetection.h"
|
#include "autodetection.h"
|
||||||
#include "ui_configurefrm.h"
|
#include "ui_configurefrm.h"
|
||||||
|
#include "browsedirtree.h"
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -326,22 +327,25 @@ void Config::updateLanguage()
|
||||||
|
|
||||||
void Config::browseFolder()
|
void Config::browseFolder()
|
||||||
{
|
{
|
||||||
QFileDialog browser(this);
|
browser = new BrowseDirtree(this);
|
||||||
if(QFileInfo(ui.mountPoint->text()).isDir())
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
browser.setDirectory(ui.mountPoint->text());
|
browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
else
|
#elif defined(Q_OS_WIN32)
|
||||||
browser.setDirectory("/media");
|
browser->setFilter(QDir::Drives);
|
||||||
browser.setReadOnly(true);
|
#endif
|
||||||
browser.setFileMode(QFileDialog::DirectoryOnly);
|
QDir d(ui.mountPoint->text());
|
||||||
browser.setAcceptMode(QFileDialog::AcceptOpen);
|
browser->setDir(d);
|
||||||
if(browser.exec()) {
|
browser->show();
|
||||||
qDebug() << browser.directory();
|
connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
|
||||||
QStringList files = browser.selectedFiles();
|
|
||||||
ui.mountPoint->setText(files.at(0));
|
|
||||||
userSettings->setValue("defaults/mountpoint", files.at(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Config::setMountpoint(QString m)
|
||||||
|
{
|
||||||
|
ui.mountPoint->setText(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Config::autodetect()
|
void Config::autodetect()
|
||||||
{
|
{
|
||||||
Autodetection detector(this);
|
Autodetection detector(this);
|
||||||
|
|
@ -394,3 +398,4 @@ void Config::autodetect()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#define CONFIGURE_H
|
#define CONFIGURE_H
|
||||||
|
|
||||||
#include "ui_configurefrm.h"
|
#include "ui_configurefrm.h"
|
||||||
|
#include "browsedirtree.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
class Config : public QDialog
|
class Config : public QDialog
|
||||||
|
|
@ -49,12 +50,15 @@ class Config : public QDialog
|
||||||
QString programPath;
|
QString programPath;
|
||||||
QUrl proxy;
|
QUrl proxy;
|
||||||
|
|
||||||
|
BrowseDirtree *browser;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setNoProxy(bool);
|
void setNoProxy(bool);
|
||||||
void setSystemProxy(bool);
|
void setSystemProxy(bool);
|
||||||
void updateLanguage(void);
|
void updateLanguage(void);
|
||||||
void browseFolder(void);
|
void browseFolder(void);
|
||||||
void autodetect(void);
|
void autodetect(void);
|
||||||
|
void setMountpoint(QString);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ SOURCES += rbutilqt.cpp \
|
||||||
../ipodpatcher/ipodpatcher.c \
|
../ipodpatcher/ipodpatcher.c \
|
||||||
../sansapatcher/sansapatcher.c \
|
../sansapatcher/sansapatcher.c \
|
||||||
irivertools/irivertools.cpp \
|
irivertools/irivertools.cpp \
|
||||||
irivertools/md5sum.cpp
|
irivertools/md5sum.cpp \
|
||||||
|
browsedirtree.cpp
|
||||||
|
|
||||||
HEADERS += rbutilqt.h \
|
HEADERS += rbutilqt.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
|
|
@ -47,7 +47,8 @@ HEADERS += rbutilqt.h \
|
||||||
irivertools/h100sums.h \
|
irivertools/h100sums.h \
|
||||||
irivertools/h120sums.h \
|
irivertools/h120sums.h \
|
||||||
irivertools/h300sums.h \
|
irivertools/h300sums.h \
|
||||||
irivertools/checksums.h
|
irivertools/checksums.h \
|
||||||
|
browsedirtree.h
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
CONFIG += release \
|
CONFIG += release \
|
||||||
|
|
@ -62,21 +63,21 @@ FORMS += rbutilqtfrm.ui \
|
||||||
installprogressfrm.ui \
|
installprogressfrm.ui \
|
||||||
configurefrm.ui \
|
configurefrm.ui \
|
||||||
installbootloaderfrm.ui \
|
installbootloaderfrm.ui \
|
||||||
|
browsedirtreefrm.ui \
|
||||||
installtalkfrm.ui
|
installtalkfrm.ui
|
||||||
|
|
||||||
|
|
||||||
RESOURCES += rbutilqt.qrc
|
RESOURCES += rbutilqt.qrc
|
||||||
|
|
||||||
TRANSLATIONS += rbutil_de.ts
|
TRANSLATIONS += rbutil_de.ts
|
||||||
QT += network
|
QT += network
|
||||||
DEFINES += RBUTIL _LARGEFILE64_SOURCE
|
DEFINES += RBUTIL _LARGEFILE64_SOURCE
|
||||||
|
|
||||||
win32{
|
win32 {
|
||||||
SOURCES += ../ipodpatcher/ipodio-win32.c
|
SOURCES += ../ipodpatcher/ipodio-win32.c
|
||||||
SOURCES += ../sansapatcher/sansaio-win32.c
|
SOURCES += ../sansapatcher/sansaio-win32.c
|
||||||
}
|
}
|
||||||
|
|
||||||
unix{
|
unix {
|
||||||
SOURCES += ../ipodpatcher/ipodio-posix.c
|
SOURCES += ../ipodpatcher/ipodio-posix.c
|
||||||
SOURCES += ../sansapatcher/sansaio-posix.c
|
SOURCES += ../sansapatcher/sansaio-posix.c
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue