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.

window.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. mTabWidget->setCurrentIndex(0);
  33. switchActiveTab(0);
  34. this->setLayout(body);
  35. }
  36. void Window::switchActivePane(hex::Pane* newPane) {
  37. //TODO: Replace this garbage. It's broken.
  38. mPathBar->setText(newPane->getPath());
  39. QObject::connect(mButton, &QPushButton::clicked,
  40. newPane, &hex::Pane::moveUp);
  41. //QObject::connect(mPathBar, &QLineEdit::textChanged,
  42. // newPane, &hex::Pane::setPath);
  43. QObject::connect(newPane, &hex::Pane::pathChanged,
  44. mPathBar, &QLineEdit::setText);
  45. QObject::connect(newPane, &hex::Pane::folderChanged,
  46. this, &Window::changeFolder);
  47. }
  48. void Window::switchActiveTab(int newTab) {
  49. switchActivePane(dynamic_cast<hex::Pane*>(mTabWidget->widget(newTab)));
  50. }
  51. void Window::changeFolder(const QString& newFolder) {
  52. mTabWidget->setTabText(mTabWidget->currentIndex(), newFolder);
  53. }