You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7 KiB

#include "window.h"
#include "pane.h"
#include <QPushButton>
#include <QListView>
#include <QStandardItemModel>
#include <QFileSystemModel>
#include <QString>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDesktopServices>
#include <QUrl>
#include <QLineEdit>
#include <QTabWidget>
#include <iostream>
Window::Window(QWidget *parent) :
QWidget(parent)
{
auto body = new QVBoxLayout(this);
auto navbar = new QHBoxLayout();
mButton = new QPushButton("^");
mPathBar = new QLineEdit();
navbar->addWidget(mButton);
navbar->addWidget(mPathBar);
body->addLayout(navbar);
mTabWidget = new QTabWidget;
body->addWidget(mTabWidget);
mTabWidget->addTab(new hex::Pane, "1");
mTabWidget->addTab(new hex::Pane, "2");
mTabWidget->addTab(new hex::Pane, "3");
QObject::connect(mTabWidget, &QTabWidget::currentChanged,
this, &Window::switchActiveTab);
mTabWidget->setCurrentIndex(0);
switchActiveTab(0);
this->setLayout(body);
}
void Window::switchActivePane(hex::Pane* newPane) {
//TODO: Replace this garbage. It's broken.
mPathBar->setText(newPane->getPath());
QObject::connect(mButton, &QPushButton::clicked,
newPane, &hex::Pane::moveUp);
//QObject::connect(mPathBar, &QLineEdit::textChanged,
// newPane, &hex::Pane::setPath);
QObject::connect(newPane, &hex::Pane::pathChanged,
mPathBar, &QLineEdit::setText);
QObject::connect(newPane, &hex::Pane::folderChanged,
this, &Window::changeFolder);
}
void Window::switchActiveTab(int newTab) {
switchActivePane(dynamic_cast<hex::Pane*>(mTabWidget->widget(newTab)));
}
void Window::changeFolder(const QString& newFolder) {
mTabWidget->setTabText(mTabWidget->currentIndex(), newFolder);
}