Skip to content

Commit

Permalink
Fixed some frameless bugs & more frameless & Tweaked about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniol-lck committed Jul 4, 2024
1 parent d822353 commit de62997
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 60 deletions.
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ int main(int argc, char *argv[])

#ifdef Q_OS_WIN
if(Config().getUseFramelessWindow()){
auto titleBar = new WindowsTitleBar(&w, w.menuBar());
auto frameless = new FramelessWrapper(nullptr, &w, titleBar);
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QApplication::setAttribute(Qt::AA_NativeWindows, false);
auto frameless = new FramelessWrapper(&w);
QObject::connect(&w, &ModManager::closed, frameless, &FramelessWrapper::close);
titleBar->setParentWidget(frameless);
frameless->show();
} else
#endif
Expand Down
8 changes: 8 additions & 0 deletions src/ui/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
ui->setupUi(this);
ui->versionText->setText(kVersion);
ui->credit_label->setText(QString("Built with Qt %1\n"
"3rd-Party Libraries:\n"
"libaria2 https://aria2.github.io/\n"
"Quazip https://github.com/stachenov/quazip\n"
"cpp-semver https://github.com/easz/cpp-semver\n"
"toml++ https://github.com/marzer/tomlplusplus")
.arg(QT_VERSION_STR));

setAttribute(Qt::WA_DeleteOnClose);
#ifdef DE_KDE
//TODO: window not blur in next show
Expand Down
10 changes: 1 addition & 9 deletions src/ui/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<widget class="QLabel" name="versionText">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down Expand Up @@ -200,14 +199,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string notr="true">Qt v5.15.2
libaria2 v1.36.0
Quazip 0.7.3
toml++ v2.5.0</string>
</property>
</widget>
<widget class="QLabel" name="credit_label"/>
</item>
</layout>
</item>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/curseforge/curseforgemodbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ CurseforgeMod *CurseforgeModBrowser::selectedMod() const
return selectedMod_;
}

ExploreBrowser *CurseforgeModBrowser::another()
ExploreBrowser *CurseforgeModBrowser::another(QWidget *parent)
{
return new CurseforgeModBrowser;
return new CurseforgeModBrowser(parent);
}

void CurseforgeModBrowser::on_sortSelect_currentIndexChanged(int)
Expand Down
2 changes: 1 addition & 1 deletion src/ui/curseforge/curseforgemodbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CurseforgeModBrowser : public ExploreBrowser
QWidget *fileListWidget() const override;
CurseforgeMod *selectedMod() const;

ExploreBrowser *another() override;
ExploreBrowser *another(QWidget *parent = nullptr) override;

CurseforgeManager *manager() const;

Expand Down
10 changes: 9 additions & 1 deletion src/ui/explorebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "exploremanager.h"
#include "local/localmodpath.h"
#include "local/localmodpathmanager.h"
#include "ui/framelesswrapper.h"
#include "util/smoothscrollbar.h"

ExploreBrowser::ExploreBrowser(QWidget *parent, const QIcon &icon, const QString &name, const QUrl &url) :
Expand Down Expand Up @@ -68,7 +69,14 @@ ExploreBrowser::ExploreBrowser(QWidget *parent, const QIcon &icon, const QString
QDesktopServices::openUrl(url);
});
openDialogAction_ = menu_->addAction(QIcon::fromTheme("window-new"), tr("Open in New Dialog"), this, [=]{
another()->show();
auto b = another();
#ifdef Q_OS_WIN
if(Config().getUseFramelessWindow()){
auto frameless = new FramelessWrapper(b);
frameless->show();
} else
#endif
b->show();
});
menu_->addMenu(downloadPathSelectMenu_);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/explorebrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExploreBrowser : public Browser
explicit ExploreBrowser(QWidget *parent, const QIcon &icon, const QString &name, const QUrl &url);
virtual ~ExploreBrowser() = default;

virtual ExploreBrowser *another() = 0;
virtual ExploreBrowser *another(QWidget *parent = nullptr) = 0;

QAction *visitWebsiteAction() const;
QIcon icon() const override;
Expand Down
28 changes: 11 additions & 17 deletions src/ui/framelesswrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@
#include "windowstitlebar.h"
#include "config.hpp"

FramelessWrapper::FramelessWrapper(QWidget *parent, QWidget *widget, QMenuBar *menuBar) :
FramelessWrapper(parent, widget, new WindowsTitleBar(widget, menuBar))
FramelessWrapper::FramelessWrapper(QMainWindow *window) :
FramelessWrapper(window, window->menuBar())
{}

FramelessWrapper::FramelessWrapper(QDialog *dialog) :
FramelessWrapper((QWidget*)dialog)
{
titleBar_->setParentWidget(this);
connect(dialog, &QDialog::finished, this, &FramelessWrapper::close);
}

FramelessWrapper::FramelessWrapper(QWidget *parent, QWidget *widget, WindowsTitleBar *titleBar) :
QMainWindow(parent),
titleBar_(titleBar)
FramelessWrapper::FramelessWrapper(QWidget *widget, QMenuBar *menuBar) :
QMainWindow(widget->parentWidget()),
titleBar_(new WindowsTitleBar(widget, menuBar))
{
// setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMaximizeButtonHint);
titleBar_->setParentWidget(this);

auto w = new QWidget(this);
auto layout = new QVBoxLayout;
Expand All @@ -39,12 +43,6 @@ FramelessWrapper::FramelessWrapper(QWidget *parent, QWidget *widget, WindowsTitl
setCentralWidget(w);

updateBlur();

#ifdef Q_OS_WIN
// HWND hwnd = (HWND)winId();
// DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
// ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
#endif //Q_OS_WIN
}

void FramelessWrapper::updateBlur()
Expand All @@ -56,11 +54,7 @@ void FramelessWrapper::updateBlur()
if(setWindowCompositionAttribute){
ACCENT_STATE as;
if(Config().getEnableBlurBehind()){
// qDebug() << isMoving_;
// if(isMoving_)
as = ACCENT_ENABLE_BLURBEHIND;
// else
// as = ACCENT_ENABLE_ACRYLICBLURBEHIND;
}
else
as = ACCENT_ENABLE_GRADIENT;
Expand Down
8 changes: 3 additions & 5 deletions src/ui/framelesswrapper.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#ifndef FRAMELESSWRAPPER_H
#define FRAMELESSWRAPPER_H

#include <QMenuBar>
#include <QMainWindow>

class QMainWindow;
class WindowsTitleBar;

class FramelessWrapper : public QMainWindow
{
Q_OBJECT

public:
FramelessWrapper(QWidget *parent, QWidget *widget, QMenuBar *menuBar = nullptr);
FramelessWrapper(QWidget *parent, QWidget *widget, WindowsTitleBar *titleBar);
FramelessWrapper(QMainWindow *window);
FramelessWrapper(QDialog *dialog);
FramelessWrapper(QWidget *widget, QMenuBar *menuBar = nullptr);

private slots:
void updateBlur();
Expand All @@ -25,7 +24,6 @@ private slots:

private:
WindowsTitleBar *titleBar_;
bool isMoving_ = false;
};

#endif // FRAMELESSWRAPPER_H
4 changes: 2 additions & 2 deletions src/ui/github/githubrepobrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ void GitHubRepoBrowser::updateUi()

}

ExploreBrowser *GitHubRepoBrowser::another()
ExploreBrowser *GitHubRepoBrowser::another(QWidget *parent)
{
return new GitHubRepoBrowser(nullptr, info_);
return new GitHubRepoBrowser(parent, info_);
}

void GitHubRepoBrowser::loadMore()
Expand Down
2 changes: 1 addition & 1 deletion src/ui/github/githubrepobrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public slots:
void searchModByPathInfo(LocalModPath *path) override;
void updateUi() override;

ExploreBrowser *another() override;
ExploreBrowser *another(QWidget *parent = nullptr) override;

signals:
void downloadPathChanged(LocalModPath *path);
Expand Down
16 changes: 9 additions & 7 deletions src/ui/modmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ ModManager::~ModManager()
delete ui;
}

QMenuBar *ModManager::menuBar() const
{
return ui->menubar;
}

void ModManager::updateUi()
{
pageSwitcher_.updateUi();
Expand Down Expand Up @@ -255,7 +250,14 @@ void ModManager::on_actionPreferences_triggered()
connect(preferences, &Preferences::accepted, this, &ModManager::updateUi, Qt::UniqueConnection);
connect(preferences, &Preferences::accepted, this, &ModManager::setProxy, Qt::UniqueConnection);
connect(preferences, &Preferences::accepted, QAria2::qaria2(), &QAria2::updateOptions, Qt::UniqueConnection);
preferences->exec();

#ifdef Q_OS_WIN
if(config_.getUseFramelessWindow()){
auto frameless = new FramelessWrapper(preferences);
frameless->show();
} else
#endif
preferences->exec();
}

void ModManager::on_actionManage_Browser_triggered()
Expand Down Expand Up @@ -319,7 +321,7 @@ void ModManager::on_action_About_Mod_Manager_triggered()
auto dialog = new AboutDialog(this);
#ifdef Q_OS_WIN
if(config_.getUseFramelessWindow()){
auto frameless = new FramelessWrapper(this, dialog);
auto frameless = new FramelessWrapper(dialog);
frameless->show();
} else
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/ui/modmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class ModManager : public QMainWindow
ModManager(QWidget *parent = nullptr);
~ModManager();

QMenuBar *menuBar() const;

signals:
void menuBarChanged();
void closed();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/modrinth/modrinthmodbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ ModrinthMod *ModrinthModBrowser::selectedMod() const
return selectedMod_;
}

ExploreBrowser *ModrinthModBrowser::another()
ExploreBrowser *ModrinthModBrowser::another(QWidget *parent)
{
return new ModrinthModBrowser;
return new ModrinthModBrowser(parent);
}

void ModrinthModBrowser::on_menuDownload_aboutToShow()
Expand Down
2 changes: 1 addition & 1 deletion src/ui/modrinth/modrinthmodbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ModrinthModBrowser : public ExploreBrowser
QWidget *fileListWidget() const override;
ModrinthMod *selectedMod() const;

ExploreBrowser *another() override;
ExploreBrowser *another(QWidget *parent = nullptr) override;

ModrinthManager *manager() const;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/optifine/optifinemodbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ void OptifineModBrowser::updateUi()
// widget->updateUi();
}

ExploreBrowser *OptifineModBrowser::another()
ExploreBrowser *OptifineModBrowser::another(QWidget *parent)
{
return new OptifineModBrowser;
return new OptifineModBrowser(parent);
}

QWidget *OptifineModBrowser::getListViewIndexWidget(const QModelIndex &index)
Expand Down
2 changes: 1 addition & 1 deletion src/ui/optifine/optifinemodbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public slots:
void searchModByPathInfo(LocalModPath *path) override;
void updateUi() override;

ExploreBrowser *another() override;
ExploreBrowser *another(QWidget *parent = nullptr) override;

private slots:
void on_actionGet_OptiFabric_triggered();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/replay/replaymodbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void ReplayModBrowser::updateUi()

}

ExploreBrowser *ReplayModBrowser::another()
ExploreBrowser *ReplayModBrowser::another(QWidget *parent)
{
return new ReplayModBrowser;
return new ReplayModBrowser(parent);
}

QWidget *ReplayModBrowser::getListViewIndexWidget(const QModelIndex &index)
Expand Down
2 changes: 1 addition & 1 deletion src/ui/replay/replaymodbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public slots:
void searchModByPathInfo(LocalModPath *path) override;
void updateUi() override;

ExploreBrowser *another() override;
ExploreBrowser *another(QWidget *parent = nullptr) override;

private slots:
void on_versionSelect_currentIndexChanged(int index);
Expand Down

0 comments on commit de62997

Please sign in to comment.