forked from mirrors/gio-qt
feat: new inertfaces for file and volume
This commit is contained in:
parent
7bef27bc0a
commit
bd6154c585
4 changed files with 46 additions and 0 deletions
|
@ -48,6 +48,7 @@ public:
|
||||||
|
|
||||||
static DGioFile * createFromPath(QString path, QObject *parent = nullptr);
|
static DGioFile * createFromPath(QString path, QObject *parent = nullptr);
|
||||||
static DGioFile * createFromUri(QString uri, QObject *parent = nullptr);
|
static DGioFile * createFromUri(QString uri, QObject *parent = nullptr);
|
||||||
|
static DGioFile * createFromCmdArg(QString uri, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString basename() const;
|
QString basename() const;
|
||||||
QString path() const;
|
QString path() const;
|
||||||
|
|
|
@ -38,6 +38,9 @@ public:
|
||||||
~DGioVolume();
|
~DGioVolume();
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
bool canMount() const;
|
||||||
|
bool canEject() const;
|
||||||
|
bool shouldAutoMount() const;
|
||||||
|
|
||||||
QExplicitlySharedDataPointer<DGioMount> getMount();
|
QExplicitlySharedDataPointer<DGioMount> getMount();
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,27 @@ DGioFile *DGioFile::createFromUri(QString uri, QObject *parent)
|
||||||
return new DGioFile(gmmFile.release(), parent);
|
return new DGioFile(gmmFile.release(), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create a DGioFile instance for a given argument from the command line.
|
||||||
|
*
|
||||||
|
* The value of \a arg can be either a URI, an absolute path or a relative path resolved relative
|
||||||
|
* to the current working directory. This operation never fails, but the returned object might
|
||||||
|
* not support any I/O operation if \a arg points to a malformed path.
|
||||||
|
*
|
||||||
|
* \param arg A string containing either a URI, a relative or absolute path.
|
||||||
|
* \return the created DGioFile instance
|
||||||
|
*/
|
||||||
|
DGioFile *DGioFile::createFromCmdArg(QString arg, QObject *parent)
|
||||||
|
{
|
||||||
|
// ensure GIO got initialized
|
||||||
|
Gio::init();
|
||||||
|
|
||||||
|
// File::create_for_uri never falls.
|
||||||
|
Glib::RefPtr<File> gmmFile = File::create_for_commandline_arg(arg.toStdString());
|
||||||
|
|
||||||
|
return new DGioFile(gmmFile.release(), parent);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the base name (the last component of the path) of the DGioFile
|
* \brief Gets the base name (the last component of the path) of the DGioFile
|
||||||
*
|
*
|
||||||
|
|
|
@ -84,6 +84,27 @@ QString DGioVolume::name() const
|
||||||
return d->name();
|
return d->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DGioVolume::canMount() const
|
||||||
|
{
|
||||||
|
Q_D(const DGioVolume);
|
||||||
|
|
||||||
|
return d->getGmmVolumeInstance()->can_mount();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DGioVolume::canEject() const
|
||||||
|
{
|
||||||
|
Q_D(const DGioVolume);
|
||||||
|
|
||||||
|
return d->getGmmVolumeInstance()->can_eject();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DGioVolume::shouldAutoMount() const
|
||||||
|
{
|
||||||
|
Q_D(const DGioVolume);
|
||||||
|
|
||||||
|
return d->getGmmVolumeInstance()->should_automount();
|
||||||
|
}
|
||||||
|
|
||||||
// Return value can be nullptr
|
// Return value can be nullptr
|
||||||
QExplicitlySharedDataPointer<DGioMount> DGioVolume::getMount()
|
QExplicitlySharedDataPointer<DGioMount> DGioVolume::getMount()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue