55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
|
#include "ui.h"
|
||
|
|
||
|
Ui::Ui(const QStringList &args, QWidget *parent) : QWidget(parent)
|
||
|
{
|
||
|
QWidget *listWid = new QWidget(this);
|
||
|
QScrollArea *mid = new QScrollArea(this);
|
||
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||
|
|
||
|
slider = new QSlider(this);
|
||
|
listLayout = new QVBoxLayout(listWid);
|
||
|
search = new QLineEdit(this);
|
||
|
|
||
|
slider->setOrientation(Qt::Horizontal);
|
||
|
mid->setWidget(listWid);
|
||
|
mid->setWidgetResizable(true);
|
||
|
mainLayout->addWidget(search);
|
||
|
mainLayout->addWidget(mid);
|
||
|
mainLayout->addWidget(slider);
|
||
|
mainLayout->setSpacing(0);
|
||
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||
|
|
||
|
if (args.size() > 1)
|
||
|
{
|
||
|
QFileInfo info(args[1]);
|
||
|
|
||
|
info.makeAbsolute();
|
||
|
|
||
|
if (info.isFile())
|
||
|
{
|
||
|
setActiveDir(info.path());
|
||
|
setActiveFile(info.filePath());
|
||
|
}
|
||
|
else if (info.isDir())
|
||
|
{
|
||
|
setActiveDir(info.path());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
setActiveDir(QDir::homePath());
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
setActiveDir(QDir::homePath());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Ui::setActiveDir(const QString &path)
|
||
|
{
|
||
|
for (int i = 0; i < fileList.size(); ++i)
|
||
|
{
|
||
|
listLayout->removeWidget(fileList[i]);
|
||
|
}
|
||
|
}
|