Files
Sourcetrail/src/lib_gui/qt/element/QtLocationPicker.cpp
T
Eberhard Graether 2d48f0a663 ui: Rewrote project setup to wizzard
* QtProjectWizzard handles window managment logic of project setup
* QtProjectWizzardWindow is used in every step and displays QtProjectWizzardContent
* QtProjectWizzardContent is the base class for all differnt content types
* Removed Singleton from ProjectSettings
* ProjectSettings are created by wizzard and QtProjectWizzardContent can access and load
* added project type selection at start of wizzard
* added summary at end of wizzard
* show global search paths in setup and summary
* fixed layout problems after font switch
* fixed scrolling and resizing of QtDirectoryListBox
* separated QtLocationPicker to own class
2016-02-14 15:42:30 +01:00

54 lines
1.1 KiB
C++

#include "qt/element/QtLocationPicker.h"
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
QtLocationPicker::QtLocationPicker(QWidget *parent)
: QWidget(parent)
{
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(1, 1, 1, 1);
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_data = new QtLineEdit(this);
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_data->setObjectName("locationField");
m_button = new QPushButton("...");
m_button->setObjectName("moreButton");
m_button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_data);
layout->addWidget(m_button);
connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress()));
}
QString QtLocationPicker::getText()
{
return m_data->text();
}
void QtLocationPicker::setText(QString text)
{
m_data->setText(text);
}
void QtLocationPicker::clearText()
{
m_data->clear();
}
void QtLocationPicker::handleButtonPress()
{
QString file = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "");
if (!file.isEmpty())
{
m_data->setText(file);
}
}