Use phantom.scriptName instead of phantom.args[0]

1.2
IceArmy 2011-06-15 14:30:31 -07:00
parent fb99a4868d
commit 61459fab45
4 changed files with 12 additions and 3 deletions

View File

@ -130,6 +130,10 @@ class Phantom(QObject):
def scriptLookupDir(self, dirPath):
self.m_page.scriptLookupDir = dirPath
@pyqtProperty(str)
def scriptName(self):
return os.path.basename(self.m_scriptFile)
@pyqtProperty('QVariantMap')
def version(self):
version = {

View File

@ -77,8 +77,6 @@ def parseArgs(args):
if not os.path.exists(args.script):
sys.exit('No such file or directory: \'%s\'' % args.script)
args.script_args.insert(0, os.path.basename(args.script))
return args

View File

@ -142,7 +142,6 @@ Phantom::Phantom(QObject *parent)
}
// The remaining arguments are available for the script.
m_args += QFileInfo(m_scriptFile).fileName();
while (argIterator.hasNext()) {
const QString &arg = argIterator.next();
m_args += arg;
@ -242,3 +241,8 @@ void Phantom::setScriptLookupDir(const QString &dirPath)
{
m_page->setScriptLookupDir(dirPath);
}
QString Phantom::scriptName() const
{
return QFileInfo(m_scriptFile).fileName();
}

View File

@ -43,6 +43,7 @@ class Phantom: public QObject
Q_PROPERTY(QStringList args READ args)
Q_PROPERTY(QVariantMap defaultPageSettings READ defaultPageSettings)
Q_PROPERTY(QString scriptLookupDir READ scriptLookupDir WRITE setScriptLookupDir)
Q_PROPERTY(QString scriptName READ scriptName)
Q_PROPERTY(QVariantMap version READ version)
public:
@ -58,6 +59,8 @@ public:
QString scriptLookupDir() const;
void setScriptLookupDir(const QString &dirPath);
QString scriptName() const;
QVariantMap version() const;
public slots: