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.

window.cpp 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "window.h"
  2. #include "pane.h"
  3. #include <QPushButton>
  4. #include <QListView>
  5. #include <QStandardItemModel>
  6. #include <QFileSystemModel>
  7. #include <QString>
  8. #include <QHBoxLayout>
  9. #include <QVBoxLayout>
  10. #include <QDesktopServices>
  11. #include <QUrl>
  12. #include <QLineEdit>
  13. #include <QTabWidget>
  14. #include <iostream>
  15. Window::Window(QWidget *parent) :
  16. QWidget(parent)
  17. {
  18. auto body = new QVBoxLayout(this);
  19. auto navbar = new QHBoxLayout();
  20. mButton = new QPushButton("^");
  21. mPathBar = new QLineEdit();
  22. navbar->addWidget(mButton);
  23. navbar->addWidget(mPathBar);
  24. body->addLayout(navbar);
  25. mTabWidget = new QTabWidget;
  26. body->addWidget(mTabWidget);
  27. mTabWidget->addTab(new hex::Pane, "1");
  28. mTabWidget->addTab(new hex::Pane, "2");
  29. mTabWidget->addTab(new hex::Pane, "3");
  30. QObject::connect(mTabWidget, &QTabWidget::currentChanged,
  31. this, &Window::switchActiveTab);
  32. this->setLayout(body);
  33. }
  34. void Window::switchActivePane(hex::Pane* newPane) {
  35. mPathBar->setText(newPane->getPath());
  36. QObject::connect(mButton, &QPushButton::clicked,
  37. newPane, &hex::Pane::moveUp);
  38. //QObject::connect(mPathBar, &QLineEdit::textChanged,
  39. // newPane, &hex::Pane::setPath);
  40. QObject::connect(newPane, &hex::Pane::pathChanged,
  41. mPathBar, &QLineEdit::setText);
  42. }
  43. void Window::switchActiveTab(int newTab) {
  44. std::cout << newTab;
  45. switchActivePane(dynamic_cast<hex::Pane*>(mTabWidget->widget(newTab)));
  46. }