aboutsummaryrefslogtreecommitdiff
path: root/include/widgets/MainWindow.hpp
blob: 4731fe41744e124266869dbd9ce45892314b5f9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include <QMainWindow>
#include <QObject>
#include <QStackedLayout>
#include <QWebEngineView>

#include "LuaRuntime.hpp"
#include "widgets/BrowserManager.hpp"
#include "widgets/InputLine.hpp"

class EvaluationType {
public:
  EvaluationType() {}
  virtual ~EvaluationType() = default;
};
class NoopEval : public EvaluationType {};

class MainWindow : public QMainWindow {
public:
  MainWindow();

protected:
  void keyPressEvent(QKeyEvent *event) override;
  void onInputSubmit(QString input);
  void evaluateCommand(QString command);
  void hideInputLine();
  void showInputLine();
  void showURLInput(QString url, OpenType openType);
  void showCommandInput(QString command = "");

  void setEvaluationType(EvaluationType *);

private:
  BrowserManager *browserManager;
  InputLine *inputLine;
  LuaRuntime *luaRuntime;
  QStackedLayout *layout;

  EvaluationType *currentEvaluationType = new NoopEval();
};

class UrlEval : public EvaluationType {
public:
  UrlEval(OpenType type) : EvaluationType(), openType(type) {}
  OpenType type() { return openType; }

private:
  OpenType openType;
};

class CommandEval : public EvaluationType {};