From 54216c4c28b81d33bd5c8b6e3b5a6083b53093fd Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Sun, 25 Dec 2022 01:58:03 -0500 Subject: Initial commit This project can also serve as a base for other Qt projects, as necessary. --- .gitignore | 2 + CMakeLists.txt | 65 ++++++++++++++++++++ README.md | 9 +++ src/main.cpp | 11 ++++ src/mainwindow.cpp | 23 +++++++ src/mainwindow.h | 25 ++++++++ src/mainwindow.ui | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 308 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 src/main.cpp create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/mainwindow.ui diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc95448 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.cache/ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cbfe51f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.5) + +project(ActorViewer VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For Kate's LSP + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + +# add_subdirectory will happen later… +set(PROJECT_SOURCES + src/main.cpp + src/mainwindow.cpp + src/mainwindow.h + src/mainwindow.ui +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(ActorViewer + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET ActorViewer APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(ActorViewer SHARED + ${PROJECT_SOURCES} + ) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(ActorViewer + ${PROJECT_SOURCES} + ) + endif() +endif() + +target_link_libraries(ActorViewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) + +set_target_properties(ActorViewer PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER space.twilightsparkle.ActorViewer + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +install(TARGETS ActorViewer + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(ActorViewer) +endif() diff --git a/README.md b/README.md new file mode 100644 index 0000000..3cae597 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +## Building + +To build, please have CMake and the Qt library installed. Then use: + +``` +cmake -B build -DCMAKE_BUILD_TYPE=Debug # Initially +cmake --build build -j$(nproc --all) --target all # All; after modifying ui files +cmake --build build -j$(nproc --all) --target clean # To clean +``` diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..fd3e533 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..156df67 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,23 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" + +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); + QMetaObject::connectSlotsByName(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_actionOpen_triggered(bool checked) { + QMessageBox msgBox; + msgBox.setText("It works!"); + msgBox.exec(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..c2ab2b3 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void on_actionOpen_triggered(bool checked); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..3e949cf --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,173 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + Actor Viewer + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Select Status to display from list.</span></p></body></html> + + + + + + + + + 0 + 0 + 800 + 30 + + + + + File + + + + + + + Help + + + + + + View + + + + + + + + + + + + + + + + + false + + + Open... + + + Open... + + + Open... + + + Open a Mastodon data archive + + + Ctrl+O + + + + + Quit + + + Ctrl+Q + + + QAction::QuitRole + + + + + About + + + QAction::AboutRole + + + + + true + + + true + + + All toots + + + + + true + + + Public toots + + + + + true + + + Unlisted toots + + + + + true + + + Private toots + + + + + true + + + Direct messages + + + + + true + + + Only with attachment + + + Only list toots that have an attachment + + + + + listWidget + textBrowser + + + + -- cgit v1.2.3-54-g00ecf