Skip to content
Permalink
Browse files

implemented BookmarkEditDialog.(refs #79)

  • Loading branch information...
haraki committed Jun 18, 2019
1 parent 16ec5fa commit 62531b7182887fc586d101b75f513c0ef89b8d1a
Showing with 208 additions and 0 deletions.
  1. +68 −0 bookmarkeditdialog.cpp
  2. +42 −0 bookmarkeditdialog.h
  3. +95 −0 bookmarkeditdialog.ui
  4. +3 −0 farman.pro
@@ -0,0 +1,68 @@
#include <QFileDialog>
#include <QPushButton>
#include <QDebug>
#include "bookmarkeditdialog.h"
#include "ui_bookmarkeditdialog.h"

namespace Farman
{

BookmarkEditDialog::BookmarkEditDialog(const QString& currentDirPath, const BookmarkInfo& info/* = BookmarkInfo()*/, QWidget *parent/* = Q_NULLPTR*/) :
QDialog(parent),
ui(new Ui::BookmarkEditDialog),
m_currentDirPath(currentDirPath),
m_info(info)
{
ui->setupUi(this);

ui->nameLineEdit->setText(info.getName());
ui->pathLineEdit->setText(info.getPath());

checkNamePathEmpty();
}

BookmarkEditDialog::~BookmarkEditDialog()
{
delete ui;
}

void BookmarkEditDialog::accept()
{
m_info.setName(ui->nameLineEdit->text());
m_info.setPath(ui->pathLineEdit->text());

QDialog::accept();
}

void BookmarkEditDialog::on_nameLineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1);

checkNamePathEmpty();
}

void BookmarkEditDialog::on_selectPathToolButton_clicked()
{
QString dirPath = ui->pathLineEdit->text();

if(dirPath.isEmpty())
{
dirPath = m_currentDirPath;
}

dirPath = QFileDialog::getExistingDirectory(this,
tr("Select folder."),
dirPath,
QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);

ui->pathLineEdit->setText(dirPath);

checkNamePathEmpty();
}

void BookmarkEditDialog::checkNamePathEmpty()
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->nameLineEdit->text().isEmpty() && !ui->pathLineEdit->text().isEmpty());
}

} // namespace Farman
@@ -0,0 +1,42 @@
#ifndef BOOKMARKEDITDIALOG_H
#define BOOKMARKEDITDIALOG_H

#include <QDialog>
#include "bookmarkinfo.h"

namespace Ui {
class BookmarkEditDialog;
}

namespace Farman
{

class BookmarkEditDialog : public QDialog
{
Q_OBJECT

public:
explicit BookmarkEditDialog(const QString& currentDirPath, const BookmarkInfo& info = BookmarkInfo(), QWidget *parent = Q_NULLPTR);
~BookmarkEditDialog() Q_DECL_OVERRIDE;

void setBookmarkInfo(const BookmarkInfo& info) { m_info = info; }
const BookmarkInfo& getBookmarkInfo() const { return m_info; }

void accept() Q_DECL_OVERRIDE;

private slots:
void on_nameLineEdit_textChanged(const QString &arg1);
void on_selectPathToolButton_clicked();

private:
void checkNamePathEmpty();

Ui::BookmarkEditDialog *ui;

const QString m_currentDirPath;
BookmarkInfo m_info;
};

} // namespace Farman

#endif // BOOKMARKEDITDIALOG_H
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BookmarkEditDialog</class>
<widget class="QDialog" name="BookmarkEditDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>117</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name : </string>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="pathLabel">
<property name="text">
<string>Path : </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="pathLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="selectPathToolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="nameLineEdit"/>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>BookmarkEditDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>BookmarkEditDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -22,6 +22,7 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\"
INCLUDEPATH += ./QHexView/include

SOURCES += main.cpp\
bookmarkeditdialog.cpp \
bookmarkinfomodel.cpp \
bookmarkmanagerdialog.cpp \
mainwindow.cpp \
@@ -54,6 +55,7 @@ SOURCES += main.cpp\
file.cpp

HEADERS += mainwindow.h \
bookmarkeditdialog.h \
bookmarkinfo.h \
bookmarkinfomodel.h \
bookmarkmanagerdialog.h \
@@ -89,6 +91,7 @@ HEADERS += mainwindow.h \
file.h

FORMS += mainwindow.ui \
bookmarkeditdialog.ui \
bookmarkmanagerdialog.ui \
folderform.ui \
doublefolderpanel.ui \

0 comments on commit 62531b7

Please sign in to comment.
You can’t perform that action at this time.