[64efc22] | 1 | /* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) |
---|
| 2 | |
---|
| 3 | This library is free software; you can redistribute it and/or |
---|
| 4 | modify it under the terms of the GNU Library General Public |
---|
| 5 | License as published by the Free Software Foundation; either |
---|
| 6 | version 2 of the License, or (at your option) any later version. |
---|
| 7 | |
---|
| 8 | This library is distributed in the hope that it will be useful, |
---|
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 11 | Library General Public License for more details. |
---|
| 12 | |
---|
| 13 | You should have received a copy of the GNU Library General Public License |
---|
| 14 | along with this library; see the file COPYING.LIB. If not, write to |
---|
| 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
---|
| 16 | Boston, MA 02110-1301, USA. |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #include <QApplication> |
---|
| 21 | #include <QtDebug> |
---|
| 22 | #include <QIcon> |
---|
| 23 | #include <QMainWindow> |
---|
| 24 | #include <QMenuBar> |
---|
| 25 | |
---|
| 26 | #include "qtermwidget.h" |
---|
| 27 | |
---|
| 28 | int main(int argc, char *argv[]) |
---|
| 29 | { |
---|
| 30 | QApplication app(argc, argv); |
---|
| 31 | QIcon::setThemeName(QStringLiteral("oxygen")); |
---|
| 32 | QMainWindow *mainWindow = new QMainWindow(); |
---|
| 33 | |
---|
| 34 | QTermWidget *console = new QTermWidget(); |
---|
| 35 | |
---|
| 36 | QMenuBar *menuBar = new QMenuBar(mainWindow); |
---|
| 37 | QMenu *actionsMenu = new QMenu(QStringLiteral("Actions"), menuBar); |
---|
| 38 | menuBar->addMenu(actionsMenu); |
---|
| 39 | actionsMenu->addAction(QStringLiteral("Find..."), console, &QTermWidget::toggleShowSearchBar, |
---|
[fedf2a2] | 40 | QKeySequence(QLatin1String("Ctrl+Shift+F"))); |
---|
[64efc22] | 41 | actionsMenu->addAction(QStringLiteral("Copy"), console, &QTermWidget::copyClipboard, |
---|
[fedf2a2] | 42 | QKeySequence(QLatin1String("Ctrl+Shift+C"))); |
---|
[64efc22] | 43 | actionsMenu->addAction(QStringLiteral("Paste"), console, &QTermWidget::pasteClipboard, |
---|
[fedf2a2] | 44 | QKeySequence(QLatin1String("Ctrl+Shift+V"))); |
---|
[64efc22] | 45 | actionsMenu->addAction(QStringLiteral("About Qt"), &app, &QApplication::aboutQt); |
---|
| 46 | mainWindow->setMenuBar(menuBar); |
---|
| 47 | |
---|
| 48 | QFont font = QApplication::font(); |
---|
| 49 | #ifdef Q_OS_MACOS |
---|
| 50 | font.setFamily(QStringLiteral("Monaco")); |
---|
| 51 | #elif defined(Q_WS_QWS) |
---|
| 52 | font.setFamily(QStringLiteral("fixed")); |
---|
| 53 | #else |
---|
| 54 | font.setFamily(QStringLiteral("Monospace")); |
---|
| 55 | #endif |
---|
| 56 | font.setPointSize(12); |
---|
| 57 | |
---|
| 58 | console->setTerminalFont(font); |
---|
| 59 | |
---|
| 60 | // console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW); |
---|
| 61 | console->setScrollBarPosition(QTermWidget::ScrollBarRight); |
---|
| 62 | |
---|
| 63 | const auto arguments = QApplication::arguments(); |
---|
| 64 | for (const QString& arg : arguments) |
---|
| 65 | { |
---|
| 66 | if (console->availableColorSchemes().contains(arg)) |
---|
| 67 | console->setColorScheme(arg); |
---|
| 68 | if (console->availableKeyBindings().contains(arg)) |
---|
| 69 | console->setKeyBindings(arg); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | mainWindow->setCentralWidget(console); |
---|
| 73 | mainWindow->resize(600, 400); |
---|
| 74 | |
---|
| 75 | // info output |
---|
| 76 | qDebug() << "* INFO *************************"; |
---|
| 77 | qDebug() << " availableKeyBindings:" << console->availableKeyBindings(); |
---|
| 78 | qDebug() << " keyBindings:" << console->keyBindings(); |
---|
| 79 | qDebug() << " availableColorSchemes:" << console->availableColorSchemes(); |
---|
| 80 | qDebug() << "* INFO END *********************"; |
---|
| 81 | |
---|
| 82 | // real startup |
---|
| 83 | QObject::connect(console, &QTermWidget::finished, mainWindow, &QMainWindow::close); |
---|
| 84 | |
---|
| 85 | mainWindow->show(); |
---|
| 86 | return app.exec(); |
---|
| 87 | } |
---|