-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
|
||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveMacros: true | ||
AlignConsecutiveAssignments: true | ||
AlignEscapedNewlines: Right | ||
AlignOperands: false | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakBeforeBraces: Attach | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializers: AfterColon | ||
ColumnLimit: 180 | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
IncludeBlocks: Preserve | ||
IndentCaseLabels: true | ||
IndentWidth: 4 | ||
PointerAlignment: Left | ||
ReflowComments: false | ||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 4 | ||
UseTab: Never | ||
|
||
AllowShortEnumsOnASingleLine: false | ||
|
||
BraceWrapping: | ||
AfterEnum: false | ||
|
||
AlignConsecutiveDeclarations: AcrossEmptyLines | ||
|
||
NamespaceIndentation: All |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
build/ | ||
.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"files.associations": { | ||
"cmath": "cpp", | ||
"cstddef": "cpp", | ||
"cstdio": "cpp", | ||
"cstdlib": "cpp", | ||
"cstring": "cpp", | ||
"ctime": "cpp", | ||
"cwchar": "cpp", | ||
"array": "cpp", | ||
"atomic": "cpp", | ||
"bit": "cpp", | ||
"*.tcc": "cpp", | ||
"charconv": "cpp", | ||
"chrono": "cpp", | ||
"compare": "cpp", | ||
"concepts": "cpp", | ||
"cstdint": "cpp", | ||
"forward_list": "cpp", | ||
"list": "cpp", | ||
"map": "cpp", | ||
"string": "cpp", | ||
"unordered_map": "cpp", | ||
"vector": "cpp", | ||
"exception": "cpp", | ||
"algorithm": "cpp", | ||
"functional": "cpp", | ||
"iterator": "cpp", | ||
"memory": "cpp", | ||
"memory_resource": "cpp", | ||
"numeric": "cpp", | ||
"optional": "cpp", | ||
"random": "cpp", | ||
"ratio": "cpp", | ||
"string_view": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"utility": "cpp", | ||
"format": "cpp", | ||
"initializer_list": "cpp", | ||
"iomanip": "cpp", | ||
"iosfwd": "cpp", | ||
"istream": "cpp", | ||
"limits": "cpp", | ||
"mutex": "cpp", | ||
"new": "cpp", | ||
"ostream": "cpp", | ||
"span": "cpp", | ||
"sstream": "cpp", | ||
"stdexcept": "cpp", | ||
"stdfloat": "cpp", | ||
"streambuf": "cpp", | ||
"cctype": "cpp", | ||
"cinttypes": "cpp", | ||
"typeinfo": "cpp", | ||
"variant": "cpp", | ||
"__bit_reference": "cpp", | ||
"__hash_table": "cpp", | ||
"__node_handle": "cpp", | ||
"__split_buffer": "cpp", | ||
"__tree": "cpp", | ||
"__verbose_abort": "cpp", | ||
"cwctype": "cpp", | ||
"locale": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
# Get version | ||
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW) | ||
string(STRIP ${VER_RAW} VER) | ||
|
||
project(hyprland-qtutils VERSION ${VER} LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 23) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2 WaylandClient) | ||
find_package(PkgConfig REQUIRED) | ||
|
||
pkg_check_modules(hyprutils REQUIRED IMPORTED_TARGET hyprutils) | ||
|
||
qt_standard_project_setup(REQUIRES 6.5) | ||
|
||
add_subdirectory(utils/dialog) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(hyprland-dialog VERSION ${VER} LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 23) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2 WaylandClient) | ||
find_package(PkgConfig REQUIRED) | ||
|
||
pkg_check_modules(hyprutils REQUIRED IMPORTED_TARGET hyprutils) | ||
|
||
qt_standard_project_setup(REQUIRES 6.5) | ||
|
||
qt_add_executable(hyprland-dialog | ||
main.cpp | ||
Dialog.cpp | ||
) | ||
|
||
qt_add_qml_module(hyprland-dialog | ||
URI org.hyprland.dialog | ||
VERSION 1.0 | ||
QML_FILES main.qml | ||
) | ||
|
||
target_link_libraries(hyprland-dialog PRIVATE | ||
Qt6::Widgets Qt6::QuickControls2 Qt6::WaylandClientPrivate PkgConfig::hyprutils | ||
) | ||
|
||
|
||
include(GNUInstallDirs) | ||
install(TARGETS hyprland-dialog | ||
BUNDLE DESTINATION . | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "Dialog.hpp" | ||
#include <print> | ||
#include <hyprutils/string/String.hpp> | ||
using namespace Hyprutils::String; | ||
|
||
CDialog::CDialog(QObject* parent) : QObject(parent) { | ||
; | ||
} | ||
|
||
void CDialog::onButtonPress(QString buttonName) { | ||
std::print("{}\n", trim(buttonName.toStdString())); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QQmlApplicationEngine> | ||
#include <QPixmap> | ||
#include <QIcon> | ||
#include <qcontainerfwd.h> | ||
#include <qqmlintegration.h> | ||
#include <qtmetamacros.h> | ||
|
||
class CDialog : public QObject { | ||
Q_OBJECT; | ||
QML_NAMED_ELEMENT(Dialog); | ||
QML_SINGLETON; | ||
Q_PROPERTY(QString dialogTitle MEMBER title CONSTANT); | ||
Q_PROPERTY(QString dialogText MEMBER text CONSTANT); | ||
Q_PROPERTY(QVector<QString> dialogButtons MEMBER buttons CONSTANT); | ||
|
||
public: | ||
explicit CDialog(QObject* parent = nullptr); | ||
|
||
QString title, text; | ||
QVector<QString> buttons; | ||
|
||
Q_INVOKABLE void onButtonPress(QString buttonName = ""); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "Dialog.hpp" | ||
#include <hyprutils/string/VarList.hpp> | ||
#include <print> | ||
#include <qapplication.h> | ||
#include <qqmlapplicationengine.h> | ||
#include <qquickstyle.h> | ||
#include <qtenvironmentvariables.h> | ||
#include <QQmlContext> | ||
|
||
using namespace Hyprutils::String; | ||
|
||
int main(int argc, char* argv[]) { | ||
// disable logs to not trash the stdout | ||
qputenv("QT_LOGGING_RULES", QByteArray("*.debug=false;qml=false")); | ||
|
||
QString appTitle; | ||
auto dialog = new CDialog(); | ||
|
||
for (int i = 1; i < argc; ++i) { | ||
std::string_view arg = argv[i]; | ||
|
||
if (arg == "--title") { | ||
if (i + 1 >= argc) { | ||
std::print(stderr, "--title requires a parameter\n"); | ||
return 1; | ||
} | ||
|
||
dialog->title = argv[i + 1]; | ||
|
||
i++; | ||
continue; | ||
} | ||
|
||
if (arg == "--apptitle") { | ||
if (i + 1 >= argc) { | ||
std::print(stderr, "--apptitle requires a parameter\n"); | ||
return 1; | ||
} | ||
|
||
appTitle = argv[i + 1]; | ||
|
||
i++; | ||
continue; | ||
} | ||
|
||
if (arg == "--text") { | ||
if (i + 1 >= argc) { | ||
std::print(stderr, "--text requires a parameter\n"); | ||
return 1; | ||
} | ||
|
||
dialog->text = argv[i + 1]; | ||
|
||
i++; | ||
continue; | ||
} | ||
|
||
if (arg == "--buttons") { | ||
if (i + 1 >= argc) { | ||
std::print(stderr, "--buttons requires a parameter\n"); | ||
return 1; | ||
} | ||
|
||
CVarList buttonz(argv[i + 1], 0, ';', true); | ||
|
||
for (auto& b : buttonz) { | ||
dialog->buttons.emplace_back(b.c_str()); | ||
} | ||
|
||
i++; | ||
continue; | ||
} | ||
|
||
std::print(stderr, "invalid arg {}\n", argv[i]); | ||
return 1; | ||
} | ||
|
||
QApplication app(argc, argv); | ||
app.setApplicationName(appTitle.isEmpty() ? dialog->title : appTitle); | ||
|
||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) | ||
QQuickStyle::setStyle("org.kde.desktop"); | ||
|
||
QQmlApplicationEngine engine; | ||
engine.rootContext()->setContextProperty("dialog", dialog); | ||
engine.load("qrc:/qt/qml/org/hyprland/dialog/main.qml"); | ||
|
||
return app.exec(); | ||
} |
Oops, something went wrong.