Change log to be a QMainWindow
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
parent
ef3bf75715
commit
d77889f26d
10 changed files with 73 additions and 86 deletions
|
@ -52,6 +52,7 @@
|
|||
#include "tools/GenericProfiler.h"
|
||||
#include "ui/InstanceWindow.h"
|
||||
#include "ui/MainWindow.h"
|
||||
#include "ui/ViewLogWindow.h"
|
||||
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
#include "ui/instanceview/AccessibleInstanceView.h"
|
||||
|
@ -1691,6 +1692,20 @@ MainWindow* Application::showMainWindow(bool minimized)
|
|||
return m_mainWindow;
|
||||
}
|
||||
|
||||
ViewLogWindow* Application::showLogWindow()
|
||||
{
|
||||
if (m_viewLogWindow) {
|
||||
m_viewLogWindow->setWindowState(m_viewLogWindow->windowState() & ~Qt::WindowMinimized);
|
||||
m_viewLogWindow->raise();
|
||||
m_viewLogWindow->activateWindow();
|
||||
} else {
|
||||
m_viewLogWindow = new ViewLogWindow();
|
||||
connect(m_viewLogWindow, &ViewLogWindow::isClosing, this, &Application::on_windowClose);
|
||||
m_openWindows++;
|
||||
}
|
||||
return m_viewLogWindow;
|
||||
}
|
||||
|
||||
InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString page)
|
||||
{
|
||||
if (!instance)
|
||||
|
|
|
@ -55,6 +55,7 @@ class LaunchController;
|
|||
class LocalPeer;
|
||||
class InstanceWindow;
|
||||
class MainWindow;
|
||||
class ViewLogWindow;
|
||||
class SetupWizard;
|
||||
class GenericPageProvider;
|
||||
class QFile;
|
||||
|
@ -183,6 +184,7 @@ class Application : public QApplication {
|
|||
|
||||
InstanceWindow* showInstanceWindow(InstancePtr instance, QString page = QString());
|
||||
MainWindow* showMainWindow(bool minimized = false);
|
||||
ViewLogWindow* showLogWindow();
|
||||
|
||||
void updateIsRunning(bool running);
|
||||
bool updatesAreAllowed();
|
||||
|
@ -290,6 +292,9 @@ class Application : public QApplication {
|
|||
// main window, if any
|
||||
MainWindow* m_mainWindow = nullptr;
|
||||
|
||||
// log window, if any
|
||||
ViewLogWindow* m_viewLogWindow = nullptr;
|
||||
|
||||
// peer launcher instance connector - used to implement single instance launcher and signalling
|
||||
LocalPeer* m_peerInstance = nullptr;
|
||||
|
||||
|
|
|
@ -847,6 +847,8 @@ SET(LAUNCHER_SOURCES
|
|||
ui/MainWindow.cpp
|
||||
ui/InstanceWindow.h
|
||||
ui/InstanceWindow.cpp
|
||||
ui/ViewLogWindow.h
|
||||
ui/ViewLogWindow.cpp
|
||||
|
||||
# FIXME: maybe find a better home for this.
|
||||
FileIgnoreProxy.cpp
|
||||
|
@ -1098,8 +1100,6 @@ SET(LAUNCHER_SOURCES
|
|||
ui/dialogs/ResourceUpdateDialog.h
|
||||
ui/dialogs/InstallLoaderDialog.cpp
|
||||
ui/dialogs/InstallLoaderDialog.h
|
||||
ui/dialogs/ViewLogDialog.cpp
|
||||
ui/dialogs/ViewLogDialog.h
|
||||
|
||||
ui/dialogs/skins/SkinManageDialog.cpp
|
||||
ui/dialogs/skins/SkinManageDialog.h
|
||||
|
@ -1258,7 +1258,6 @@ qt_wrap_ui(LAUNCHER_UI
|
|||
ui/dialogs/ScrollMessageBox.ui
|
||||
ui/dialogs/BlockedModsDialog.ui
|
||||
ui/dialogs/ChooseProviderDialog.ui
|
||||
ui/dialogs/ViewLogDialog.ui
|
||||
ui/dialogs/skins/SkinManageDialog.ui
|
||||
)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ MessageLevel::Enum MessageLevel::getLevel(const QString& levelName)
|
|||
return MessageLevel::Message;
|
||||
else if (name == "WARNING" || name == "WARN")
|
||||
return MessageLevel::Warning;
|
||||
else if (name == "ERROR")
|
||||
else if (name == "ERROR" || name == "CRITICAL")
|
||||
return MessageLevel::Error;
|
||||
else if (name == "FATAL")
|
||||
return MessageLevel::Fatal;
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
#include "InstanceWindow.h"
|
||||
|
||||
#include "ui/GuiUtil.h"
|
||||
#include "ui/ViewLogWindow.h"
|
||||
#include "ui/dialogs/AboutDialog.h"
|
||||
#include "ui/dialogs/CopyInstanceDialog.h"
|
||||
#include "ui/dialogs/CreateShortcutDialog.h"
|
||||
|
@ -103,7 +104,6 @@
|
|||
#include "ui/dialogs/NewInstanceDialog.h"
|
||||
#include "ui/dialogs/NewsDialog.h"
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
#include "ui/dialogs/ViewLogDialog.h"
|
||||
#include "ui/instanceview/InstanceDelegate.h"
|
||||
#include "ui/instanceview/InstanceProxyModel.h"
|
||||
#include "ui/instanceview/InstanceView.h"
|
||||
|
@ -240,10 +240,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
}
|
||||
|
||||
{ // logs viewing
|
||||
connect(ui->actionViewLog, &QAction::triggered, this, [this] {
|
||||
ViewLogDialog dialog(this);
|
||||
dialog.exec();
|
||||
});
|
||||
connect(ui->actionViewLog, &QAction::triggered, this, [] { APPLICATION->showLogWindow(); });
|
||||
}
|
||||
|
||||
// add the toolbar toggles to the view menu
|
||||
|
|
25
launcher/ui/ViewLogWindow.cpp
Normal file
25
launcher/ui/ViewLogWindow.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <QCloseEvent>
|
||||
|
||||
#include "ViewLogWindow.h"
|
||||
|
||||
#include "ui/pages/instance/OtherLogsPage.h"
|
||||
|
||||
ViewLogWindow::ViewLogWindow(QWidget* parent)
|
||||
: QMainWindow(parent), m_page(new OtherLogsPage("launcher-logs", tr("Launcher Logs"), "Launcher-Logs", nullptr, parent))
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowIcon(APPLICATION->getThemedIcon("log"));
|
||||
setWindowTitle(tr("View Launcher Logs"));
|
||||
setCentralWidget(m_page);
|
||||
setMinimumSize(m_page->size());
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
m_page->opened();
|
||||
show();
|
||||
}
|
||||
|
||||
void ViewLogWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
m_page->closed();
|
||||
emit isClosing();
|
||||
event->accept();
|
||||
}
|
23
launcher/ui/ViewLogWindow.h
Normal file
23
launcher/ui/ViewLogWindow.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
class OtherLogsPage;
|
||||
|
||||
class ViewLogWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewLogWindow(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void isClosing();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
|
||||
private:
|
||||
OtherLogsPage* m_page;
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
#include "ViewLogDialog.h"
|
||||
#include "ui_ViewLogDialog.h"
|
||||
|
||||
#include "ui/pages/instance/OtherLogsPage.h"
|
||||
|
||||
ViewLogDialog::ViewLogDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::ViewLogDialog)
|
||||
, m_page(new OtherLogsPage("launcher-logs", tr("Launcher Logs"), "Launcher-Logs", nullptr, parent))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->verticalLayout->insertWidget(0, m_page);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
m_page->opened();
|
||||
}
|
||||
|
||||
ViewLogDialog::~ViewLogDialog()
|
||||
{
|
||||
m_page->closed();
|
||||
delete ui;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QHash>
|
||||
|
||||
namespace Ui {
|
||||
class ViewLogDialog;
|
||||
}
|
||||
|
||||
class OtherLogsPage;
|
||||
|
||||
class ViewLogDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewLogDialog(QWidget* parent = nullptr);
|
||||
~ViewLogDialog();
|
||||
|
||||
private:
|
||||
Ui::ViewLogDialog* ui;
|
||||
OtherLogsPage* m_page;
|
||||
};
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewLogDialog</class>
|
||||
<widget class="QDialog" name="ViewLogDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>825</width>
|
||||
<height>782</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>View Launcher Logs</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Add table
Add a link
Reference in a new issue