61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
|
#pragma execution_character_set("utf-8")
|
|||
|
|
|||
|
#include "TitleBar.h"
|
|||
|
#include "mainwindow.h"
|
|||
|
#include "easylogging++.h"
|
|||
|
#include "common.h"
|
|||
|
#include <QDesktopServices>
|
|||
|
#include <QCoreApplication>
|
|||
|
TitleBar::TitleBar(QWidget* parent)
|
|||
|
: EventModule("TitleBar"), _parent(parent)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
TitleBar::~TitleBar()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
bool TitleBar::onMessage(const std::string& eventName, json& parameter)
|
|||
|
{
|
|||
|
auto parent = (MainWindow*)_parent;
|
|||
|
TRY{
|
|||
|
if (eventName == "closed") {
|
|||
|
parent->Close();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else if (eventName == "open-log") {
|
|||
|
QString dir = QCoreApplication::applicationDirPath();
|
|||
|
QDate date = QDate::currentDate();
|
|||
|
if (!QDesktopServices::openUrl("file:" + dir + "/QTlog/" + date.toString("yyyyMMdd") + ".log")) {
|
|||
|
parameter["error"] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־";
|
|||
|
}
|
|||
|
LOG(INFO) << CommonHelper::qstringToUtf8(QUrl(dir + "/QTlog/" + date.toString("yyyyMMdd") + ".log").toString());
|
|||
|
LOG(INFO) << CommonHelper::utf8ToStdString("open-log Sendto web.......");
|
|||
|
return true;
|
|||
|
}
|
|||
|
else if (eventName == "minimized") {
|
|||
|
parent->showMinimized();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else if (eventName == "maximized") {
|
|||
|
parent->changeMaximize();
|
|||
|
return true;
|
|||
|
}
|
|||
|
/*else if (eventName == "titlebar-hover") {
|
|||
|
if (parameter["data"].is_boolean()) {
|
|||
|
((MainWindow*)_parent)->titleBarRegion(parameter["data"]);
|
|||
|
}
|
|||
|
return true;
|
|||
|
}*/
|
|||
|
}
|
|||
|
CATCH(parameter);
|
|||
|
|
|||
|
return EventModule::onMessage(eventName, parameter);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void TitleBar::setTitleText(const std::string title)
|
|||
|
{
|
|||
|
send<std::string>("change-title", title);
|
|||
|
}
|