-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
1 parent
175c8b1
commit 5935fa3
Showing
18 changed files
with
219 additions
and
41 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
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,80 @@ | ||
/** | ||
* This file is part of the "libterminal" project | ||
* Copyright (c) 2019-2020 Christian Parpart <christian@parpart.family> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <contour/Controller.h> | ||
#include <contour/TerminalWindow.h> | ||
|
||
#include <QtCore/QProcess> | ||
|
||
using namespace std; | ||
|
||
namespace contour { | ||
|
||
Controller::Controller(std::string _programPath, | ||
config::Config _config, | ||
std::string _profileName) : | ||
programPath_{ move(_programPath) }, | ||
config_{ move(_config) }, | ||
profileName_{ move(_profileName) } | ||
{ | ||
// systrayIcon_ = new QSystemTrayIcon(nullptr); | ||
// systrayIcon_->show(); | ||
// TODO: systrayIcon_: add icon | ||
// TODO: systrayIcon_: add context menu? | ||
|
||
connect(this, &Controller::started, this, [this]() { newWindow(); }); | ||
} | ||
|
||
Controller::~Controller() | ||
{ | ||
} | ||
|
||
void Controller::newWindow() | ||
{ | ||
auto mainWindow = new TerminalWindow{ | ||
config_, | ||
profileName_, | ||
programPath_ | ||
}; | ||
mainWindow->show(); | ||
|
||
QObject::connect(mainWindow, &TerminalWindow::showNotification, | ||
this, &Controller::showNotification); | ||
} | ||
|
||
void Controller::showNotification(QString const& _title, QString const& _content) | ||
{ | ||
// systrayIcon_->showMessage( | ||
// _title, | ||
// _content, | ||
// QSystemTrayIcon::MessageIcon::Information, | ||
// 10 * 1000 | ||
// ); | ||
|
||
#if defined(__linux__) | ||
// XXX requires notify-send to be installed. | ||
QStringList args; | ||
args.append("--urgency=low"); | ||
args.append("--expire-time=10000"); | ||
args.append("--category=terminal"); | ||
args.append(_title); | ||
args.append(_content); | ||
QProcess::execute(QString::fromLatin1("notify-send"), args); | ||
#elif defined(__APPLE__) | ||
// TODO: use Growl? | ||
#elif defined(_WIN32) | ||
// TODO: use Toast | ||
#endif | ||
} | ||
|
||
} // end namespace |
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,45 @@ | ||
/** | ||
* This file is part of the "libterminal" project | ||
* Copyright (c) 2019-2020 Christian Parpart <christian@parpart.family> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
#include <contour/Config.h> | ||
|
||
#include <QtCore/QThread> | ||
#include <QtWidgets/QSystemTrayIcon> | ||
|
||
#include <string> | ||
|
||
namespace contour { | ||
|
||
class Controller : public QThread { | ||
public: | ||
Controller(std::string _programPath, | ||
contour::config::Config _config, | ||
std::string _profileName); | ||
|
||
~Controller(); | ||
|
||
public slots: | ||
void newWindow(); | ||
void showNotification(QString const& _title, QString const& _content); | ||
|
||
private: | ||
std::string programPath_; | ||
contour::config::Config config_; | ||
std::string profileName_; | ||
|
||
QSystemTrayIcon* systrayIcon_ = nullptr; | ||
}; | ||
|
||
} // end namespace |
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
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
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
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
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
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
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
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
Oops, something went wrong.