Browse Source

fixed moc, top bar

master
hex 4 years ago
parent
commit
ca26e6e838
5 changed files with 39 additions and 11 deletions
  1. 12
    5
      CMakeLists.txt
  2. 2
    2
      include/window.h
  3. 5
    0
      src/pane.cpp
  4. 5
    1
      src/pane.h
  5. 15
    3
      src/window.cpp

+ 12
- 5
CMakeLists.txt View File

@@ -1,15 +1,22 @@
cmake_minimum_required (VERSION 3.6)
project ("hexfm")
file (GLOB_RECURSE SOURCES "src/*.cpp")
include_directories("./include")


find_package(Threads REQUIRED)
find_package(Qt5Widgets)

set(CMAKE_AUTOMOC on)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(CMAKE_AUTOMOC on)

qt_wrap_cpp(hexfm SOURCES ./include/pane.h)

file (GLOB_RECURSE SOURCES "src/*.cpp")
include_directories("./include")

add_executable(hexfm ${SOURCES})

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
find_package(Qt5Widgets)
target_link_libraries(hexfm Qt5::Widgets ${CMAKE_THREAD_LIBS_INIT})


+ 2
- 2
include/window.h View File

@@ -5,8 +5,7 @@


class QPushButton;
class QListView;
class QFileSystemModel;
class QLineEdit;

class Window : public QWidget {
public:
@@ -16,4 +15,5 @@ public slots:
private:
QPushButton *mButton;
QLineEdit *mPathBar;
};

+ 5
- 0
src/pane.cpp View File

@@ -25,11 +25,14 @@ Pane::Pane(QWidget* parent) :

bool Pane::setPath(const QString& path) {
changeIndex(mModel->index(path));
return true;
}

void Pane::changeIndex(const QModelIndex& index) {
if (mModel->isDir(index)) {
mView->setRootIndex(index);

emit pathChanged(mModel->filePath(index));
} else {
//open file
}
@@ -40,3 +43,5 @@ void Pane::moveUp() {
}

}

#include "moc_pane.cpp"

include/pane.h → src/pane.h View File

@@ -9,6 +9,7 @@ class QFileSystemModel;
namespace hex {

class Pane : public QWidget {
Q_OBJECT
public:
explicit Pane(QWidget *parent = 0);

@@ -16,7 +17,10 @@ public slots:
bool setPath(const QString& path);
void changeIndex(const QModelIndex& index);
void moveUp();

signals:
void pathChanged(const QString& newPath);

private:
QListView* mView;
QFileSystemModel* mModel;

+ 15
- 3
src/window.cpp View File

@@ -10,19 +10,31 @@
#include <QVBoxLayout>
#include <QDesktopServices>
#include <QUrl>
#include <QLineEdit>

Window::Window(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* navbar = new QVBoxLayout(this);
auto body = new QVBoxLayout(this);
auto navbar = new QHBoxLayout();

mButton = new QPushButton("^");

mPathBar = new QLineEdit();
navbar->addWidget(mButton);
navbar->addWidget(mPathBar);

body->addLayout(navbar);
auto pane = new hex::Pane;
navbar->addWidget(pane);
body->addWidget(pane);

this->setLayout(navbar);
this->setLayout(body);

QObject::connect(mButton, &QPushButton::clicked,
pane, &hex::Pane::moveUp);
QObject::connect(mPathBar, &QLineEdit::textChanged,
pane, &hex::Pane::setPath);
QObject::connect(pane, &hex::Pane::pathChanged,
mPathBar, &QLineEdit::setText);
}


Loading…
Cancel
Save