Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ osx
*.log
*.qm
.DS_Store
.vscode
.cursor
# SpecStory explanation file
.specstory
.cursorindexingignore
# SpecStory explanation file
.specstory/.what-is-this.md
28 changes: 25 additions & 3 deletions src/app/bmwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ BMWindow::BMWindow(QWidget *parent)
: BMWindowBaseClass(parent), d_ptr(new BMWindowPrivate(this))
{
Q_D(BMWindow);
qDebug() << "Initializing Boot Maker window";

setFixedSize(440, 550);

Expand All @@ -62,6 +63,7 @@ BMWindow::BMWindow(QWidget *parent)
#else
d->interface = &BMInterface::ref();
#endif
qDebug() << "BMInterface initialized";

// init about info
QString descriptionText = tr("Boot Maker is a simple tool to write system image files into USB flash drives and other media.");
Expand Down Expand Up @@ -148,11 +150,13 @@ BMWindow::BMWindow(QWidget *parent)
slot_ThemeChange();

connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::newProcessInstance, this, [ = ] {
qDebug() << "New process instance detected, activating window";
this->activateWindow();
});
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,
this, &BMWindow :: slot_ThemeChange);
connect(d->isoWidget, &ISOSelectView::isoFileSelected, this, [ = ] {
qDebug() << "ISO file selected, transitioning to USB selection view";
slideWidget(d->isoWidget, d->usbWidget);
setProperty("bmISOFilePath", d->isoWidget->isoFilePath());
d->wsib->setCurrentPage(1);
Expand All @@ -161,6 +165,7 @@ BMWindow::BMWindow(QWidget *parent)
connect(d->isoWidget,&ISOSelectView::isoFileSelected,d->usbWidget,&UsbSelectView::getIsoFileSelectedPath);

connect(d->usbWidget, &UsbSelectView::deviceSelected, this, [ = ](const QString & partition, bool format) {
qDebug() << "Device selected - Partition:" << partition << "Format:" << format;
#ifdef Q_OS_WIN
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint);
closeflags = false;
Expand All @@ -177,7 +182,7 @@ BMWindow::BMWindow(QWidget *parent)
#endif

auto isoFilePath = property("bmISOFilePath").toString();
qDebug() << "call interface install" << partition << format;
qDebug() << "Starting installation - ISO:" << isoFilePath << "Partition:" << partition << "Format:" << format;
emit d->interface->startInstall(isoFilePath, "", partition, format);
// Linux: wait for startInstallRet() polkit authorization check result, then animate the widget.
});
Expand All @@ -186,10 +191,11 @@ BMWindow::BMWindow(QWidget *parent)
// Check polkit authorization success, not availiable on windows.
connect(d->interface, &BMInterface::startInstallRet, this, [ = ](bool success) {
if (success) {
qDebug() << "Installation authorization successful, transitioning to progress view";
slideWidget(d->usbWidget, d->progressWidget);
d->wsib->setCurrentPage(2);
} else {
qWarning() << "call interface install return failed";
qWarning() << "Installation authorization failed";

d->usbWidget->resetStartInstall();
d->usbWidget->setEnabled(true);
Expand All @@ -200,12 +206,14 @@ BMWindow::BMWindow(QWidget *parent)
#endif

connect(d->progressWidget, &ProgressView::testCancel, this, [ = ] {
qDebug() << "Installation cancelled by user";
setWindowFlags(windowFlags() | Qt::WindowCloseButtonHint);
d->resultWidget->updateResult(BMHandler::SyscExecFailed, "title", "description");
slideWidget(d->progressWidget, d->resultWidget);
d->wsib->setCurrentPage(2);
});
connect(d->usbWidget, &UsbSelectView::finish, this, [ = ](quint32 error, const QString & title, const QString & description) {
qDebug() << "USB selection finished - Error:" << error << "Title:" << title;
Qt::WindowFlags flags = Qt::WindowCloseButtonHint;
flags |= Qt::WindowSystemMenuHint;
flags |= Qt::WindowMinimizeButtonHint;
Expand All @@ -215,14 +223,16 @@ BMWindow::BMWindow(QWidget *parent)
emit d->progressWidget->finish(0, error, title, description);
});
connect(d->usbWidget, &UsbSelectView::backToPrevUI, this, [=]{
qDebug() << "User clicked back, returning to ISO selection";
slideWidget(d->usbWidget, d->isoWidget, 1);
d->wsib->setCurrentPage(0);
});
//diff mac,win,linux
connect(d->progressWidget, &ProgressView::finish,
this, [ = ](quint32 current, quint32 error, const QString & title, const QString & description) {
qDebug() << error << title << description << current;
qDebug() << "Progress finished - Current:" << current << "Error:" << error << "Title:" << title;
if (error != BMHandler::NoError) {
qWarning() << "Operation failed with error:" << error;
titlebar()->setQuitMenuDisabled(false);
#ifdef Q_OS_WIN
setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
Expand All @@ -238,6 +248,7 @@ BMWindow::BMWindow(QWidget *parent)
}
#ifdef Q_OS_LINUX
if (error == BMHandler::NoError && current == 101) {
qDebug() << "Operation completed successfully on Linux";
titlebar()->setMenuVisible(true);
titlebar()->setQuitMenuDisabled(false);
DWindowManagerHelper::instance()->setMotifFunctions(windowHandle(), DWindowManagerHelper::FUNC_CLOSE, true);
Expand All @@ -248,6 +259,7 @@ BMWindow::BMWindow(QWidget *parent)
#endif
#ifndef Q_OS_LINUX
#if defined Q_OS_Win
qDebug() << "Operation completed on Windows";
titlebar()->setQuitMenuDisabled(false);
setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
closeflags = true;
Expand All @@ -261,15 +273,18 @@ BMWindow::BMWindow(QWidget *parent)
#endif
});

qDebug() << "Starting BMInterface";
d->interface->start();
}

void BMWindow :: slot_ThemeChange()
{
Q_D(BMWindow);
qDebug() << "Theme change detected";
DPalette pa;
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
if (themeType == DGuiApplicationHelper::LightType) {
qDebug() << "Applying light theme";
pa = d->wsib->palette();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
pa.setColor(DPalette::Background, QColor(255, 255, 255));
Expand All @@ -281,6 +296,7 @@ void BMWindow :: slot_ThemeChange()
// d->wsib->setSecondaryPointColor(QColor("#96ACBD"));
d->wsib->setSecondaryPointColor(QColor(150, 172, 189, 51));
} else if (themeType == DGuiApplicationHelper::DarkType) {
qDebug() << "Applying dark theme";
pa = d->wsib->palette();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
pa.setColor(DPalette::Background, QColor("#292929"));
Expand All @@ -296,6 +312,7 @@ void BMWindow :: slot_ThemeChange()

BMWindow::~BMWindow()
{
qDebug() << "Destroying Boot Maker window";
m_pSAnimationGroup->deleteLater();
}

Expand All @@ -306,12 +323,14 @@ QString rootCommand()

void startBackend()
{
qDebug() << "Starting backend process";
QProcess::startDetached(rootCommand());
}

#if defined(Q_OS_WIN)
void BMWindow::closeEvent(QCloseEvent *event)
{
qDebug() << "Close event received, closeflags:" << closeflags;
if (closeflags == false) {
event->ignore();
} else {
Expand All @@ -322,6 +341,7 @@ void BMWindow::closeEvent(QCloseEvent *event)

void BMWindow::slideWidget(DWidget *left, DWidget *right, int iDirection)
{
qDebug() << "Sliding widgets - Direction:" << iDirection;
SlideAnimatoin* pSlideAnimation = new SlideAnimatoin;
pSlideAnimation->initAnimation(left, right, iDirection);

Expand Down Expand Up @@ -350,6 +370,7 @@ SlideAnimatoin::~SlideAnimatoin()

void SlideAnimatoin::initAnimation(DWidget* pLeftWidget, DWidget* pRightWidget, int iDirection)
{
qDebug() << "Initializing slide animation - Direction:" << iDirection;
setLeftWidget(pLeftWidget);
setRightWidget(pRightWidget);
m_pLeftWidget->show();
Expand Down Expand Up @@ -387,6 +408,7 @@ void SlideAnimatoin::setRightWidget(DWidget* pWidget)

void SlideAnimatoin::slot_AnimationGroupFinished()
{
qDebug() << "Slide animation finished";
for (int i = 0; i < this->animationCount(); i++) {
this->animationAt(i)->deleteLater();
}
Expand Down
17 changes: 15 additions & 2 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

int main(int argc, char **argv)
{
qInfo() << "Starting Boot Maker application";
Utils::initResource();
#ifndef Q_OS_WIN
#if defined(DTK_STATIC_LIB)
Expand All @@ -58,7 +59,7 @@
#endif

if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {

qInfo() << "Setting XDG_CURRENT_DESKTOP to Deepin";
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
}

Expand All @@ -73,7 +74,9 @@
// app.setTheme("light");

#ifdef Q_OS_MAC
qDebug() << "Checking root privileges on macOS";
if (switchToRoot(app)) {
qDebug() << "Switching to root user, exiting current instance";
exit(0);
}
#endif
Expand All @@ -83,21 +86,25 @@
DLogManager::registerFileAppender();

#ifndef Q_OS_MAC
qDebug() << "Setting up single instance check";
qputenv("DTK_USE_SEMAPHORE_SINGLEINSTANCE", "1");
if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) {
qDebug() << "Another instance is already running, exiting";
exit(0);
}
#endif

#ifdef Q_OS_WIN
qDebug() << "Loading fonts on Windows";
Utils::loadFonts();
app.setWindowIcon(QIcon(":/theme/light/image/deepin-boot-maker.svg"));
#endif
qDebug() << "Loading translations";
app.loadTranslator();
Utils::loadTranslate();
app.setApplicationDisplayName(QObject::tr("Boot Maker"));

qDebug() << "Boot Maker UI started.";
qDebug() << "Boot Maker UI starting";
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
DApplicationSettings savetheme;
#endif
Expand All @@ -107,17 +114,21 @@
// w.waitAuth();
auto ret = app.exec();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qInfo() << "Stopping BMInterface instance";
BMInterface::instance()->stop();
#else
qInfo() << "Stopping BMInterface reference";
BMInterface::ref().stop();
#endif
qDebug() << "Application exiting with code:" << ret;
return ret;
}

#ifdef Q_OS_WIN32
namespace Utils {
void loadFonts()
{
qInfo() << "Loading preferred fonts on Windows";
QFontDatabase database;
QStringList fontlist = database.families();

Expand All @@ -128,12 +139,14 @@
preferList.append("黑体");

foreach (QString font, preferList) {
if (fontlist.contains(font)) {

Check warning on line 142 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.
qInfo() << "Setting application font to:" << font;
QFont newFont = QFont(font);
qApp->setFont(newFont);
return;
}
}
qWarning() << "No preferred fonts found, using system default";
}
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/app/view/deviceinfoitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device,
const QString &cap, int percent, DWidget *parent)
: DWidget(parent)
{
qDebug() << "Creating DeviceInfoItem:" << name << "device:" << device << "capacity:" << cap << "percent:" << percent;
s_removeDevice = WidgetUtil::getDpiPixmap(":/theme/light/image/drive.svg", this);

auto mainLayout = new QHBoxLayout(this);
Expand Down Expand Up @@ -107,6 +108,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device,

connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,
this, [ = ] {
qDebug() << "Theme changed for device:" << name;
DPalette pa;
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
if (themeType == DGuiApplicationHelper::LightType)
Expand Down Expand Up @@ -136,6 +138,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device,
DeviceInfoItem::DeviceInfoItem(DWidget *parent) :
DeviceInfoItem("Remove Device", "NULL", "0/0G", 0, parent)
{
qDebug() << "Creating default DeviceInfoItem for device removal";
setProperty("needformat", false);
}

Expand Down
11 changes: 11 additions & 0 deletions src/app/view/formatdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
NewStr autoCutText(const QString &text, DLabel *pDesLbl)
{
if (text.isEmpty() || nullptr == pDesLbl) {
qDebug() << "Invalid input for autoCutText: empty text or null label";
return NewStr();
}

Expand All @@ -24,9 +25,11 @@
NewStr newstr;
int width = pDesLbl->width();
if (titlewidth < width) {
qDebug() << "Text fits in one line:" << strText;
newstr.strList.append(strText);
newstr.resultStr += strText;
} else {
qDebug() << "Text needs multiple lines, width:" << width << "text width:" << titlewidth;
for (int i = 0; i < strText.count(); i++) {
str += strText.at(i);

Expand All @@ -49,6 +52,7 @@
FormatDialog::FormatDialog(QWidget *parent)
: DDialog(parent)
{
qDebug() << "Initializing FormatDialog";
setFixedWidth(380);
// 设置对话框图标
setIcon(QMessageBox::standardIcon(QMessageBox::Icon::Warning));
Expand All @@ -59,8 +63,9 @@

}

void FormatDialog::initDialog(const QString &titleText, const QString &strFormatText, const QString btnMsg1, DDialog::ButtonType btnType1, const QString btnMsg2, DDialog::ButtonType btnType2)

Check warning on line 66 in src/app/view/formatdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'initDialog' is never used.

Check warning on line 66 in src/app/view/formatdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'btnMsg2' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.

Check warning on line 66 in src/app/view/formatdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'btnMsg1' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
qDebug() << "Initializing dialog with title:" << titleText;
// 设置title
if (!titleText.isEmpty())
setTitle(titleText);
Expand All @@ -75,8 +80,10 @@

// 按钮
if (btnMsg2.isEmpty()) {
qDebug() << "Adding single button:" << btnMsg1;
addButton(btnMsg1, false, btnType1);
} else {
qDebug() << "Adding two buttons:" << btnMsg1 << "and" << btnMsg2;
addButton(btnMsg1, false, btnType1);
addButton(btnMsg2, true, btnType2);
}
Expand All @@ -90,13 +97,16 @@

void FormatDialog::autoFeed(DLabel *label)
{
qDebug() << "Auto feeding text for label";
NewStr newstr = autoCutText(m_strFormatText, label);
label->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label->setFixedHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
qDebug() << "First time auto feed, adjusting size";
adjustSize();
} else {
qDebug() << "Adjusting height from" << m_iLabelOldHeight << "to" << height_lable;
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
Expand All @@ -106,6 +116,7 @@
void FormatDialog::changeEvent(QEvent *event)
{
if (event->type() == QEvent::FontChange) {
qDebug() << "Font change event detected";
Dtk::Widget::DLabel *p = findChild<Dtk::Widget::DLabel *>("ContentLabel");
if (nullptr != p) {
autoFeed(p);
Expand Down
Loading
Loading