Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
67 rader
1.7 KiB
67 rader
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); |
|
}
|
|
|