Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chandlerye committed Jun 9, 2024
1 parent e2452db commit d9d50a2
Show file tree
Hide file tree
Showing 25 changed files with 2,328 additions and 0 deletions.
39 changes: 39 additions & 0 deletions MyNote.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat


CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
fontsizedialog.cpp \
form_mode_change.cpp \
form_sql_config.cpp \
main.cpp \
mainwindow.cpp

HEADERS += \
fontsizedialog.h \
form_mode_change.h \
form_sql_config.h \
sql_config.h \
mainwindow.h

FORMS += \
form_mode_change.ui \
form_sql_config.ui \
mainwindow.ui

RC_ICONS = myico.ico

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
res.qrc
435 changes: 435 additions & 0 deletions MyNote.pro.user

Large diffs are not rendered by default.

Binary file added about.ico
Binary file not shown.
Binary file added delete.ico
Binary file not shown.
Binary file added file_output.ico
Binary file not shown.
Binary file added font.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions fontsizedialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// FontSizeDialog.cpp
#include "FontSizeDialog.h"


FontSizeDialog::FontSizeDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(tr("设置字体大小"));

QVBoxLayout *mainLayout = new QVBoxLayout(this);

// // 字体选择
// fontComboBox = new QFontComboBox(this);
// mainLayout->addWidget(fontComboBox);

// 大小选择
spinBox = new QSpinBox(this);
spinBox->setMinimum(8);
spinBox->setMaximum(72);
mainLayout->addWidget(spinBox);

// 按钮布局
QHBoxLayout *buttonLayout = new QHBoxLayout();
QPushButton *okButton = new QPushButton(tr("确定"), this);
QPushButton *cancelButton = new QPushButton(tr("取消"), this);
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
mainLayout->addLayout(buttonLayout);

connect(okButton, &QPushButton::clicked, this, &FontSizeDialog::onOkClicked);
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
}

int FontSizeDialog::fontSize() const
{
return spinBox->value();
}

void FontSizeDialog::onOkClicked()
{
accept();
}

void FontSizeDialog::setDefaultFontSize(int size)
{
spinBox->setValue(size); // 使用setValue方法设置QSpinBox的默认值
}
34 changes: 34 additions & 0 deletions fontsizedialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// FontSizeDialog.h
#ifndef FONTSIZE_DIALOG_H
#define FONTSIZE_DIALOG_H

#include <QDialog>
#include<QFontComboBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include<QSpinBox>

class QFontComboBox;
class QLabel;
class QPushButton;
class QSpinBox;

class FontSizeDialog : public QDialog
{
Q_OBJECT

public:
explicit FontSizeDialog(QWidget *parent = nullptr);
int fontSize() const;
void setDefaultFontSize(int size);

private slots:
void onOkClicked();

private:
QFontComboBox *fontComboBox;
QSpinBox *spinBox;
};

#endif // FONTSIZE_DIALOG_H
88 changes: 88 additions & 0 deletions form_mode_change.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "form_mode_change.h"
#include "ui_form_mode_change.h"

Form_mode_change::Form_mode_change(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Form_mode_change)
{
ui->setupUi(this);



this->setFixedSize(350, 100);
// 创建ButtonGroup并添加RadioButton
buttonGroup = new QButtonGroup(this);
buttonGroup->addButton(ui->local_radioButton);
buttonGroup->addButton(ui->clould_radioButton);
mode = new QString;

QSettings settings("MyNote","setting");

QString value = settings.value("mode").toString();

if (!value.isEmpty()) {
*mode = value; // 确保mode指向的QString对象被赋予settings中的"value"值,且非空

if (*mode == "QSQLITE") {
ui->local_radioButton->setChecked(true);
} else if (*mode == "QMYSQL") {
ui->clould_radioButton->setChecked(true);

}
} else {
*mode = "QSQLITE"; // 如果value为空,则默认设置mode为"QSQLITE"

ui->local_radioButton->setChecked(true); // 并且默认选中本地数据库RadioButton
}


// 连接信号和槽
connect(ui->local_radioButton, &QRadioButton::clicked, this, &Form_mode_change::onLocalRadioButtonClicked);
connect(ui->clould_radioButton, &QRadioButton::clicked, this, &Form_mode_change::onClouldRadioButtonClicked);

}

Form_mode_change::~Form_mode_change()
{
delete ui;
delete mode;
}

void Form_mode_change::onLocalRadioButtonClicked(bool checked)
{
if (checked) {
*mode = "QSQLITE";

emit modeChanged(*mode); // 发射模式改变信号
qDebug()<<*mode;
// 保存到QSettings
QSettings settings("MyNote","setting");

settings.setValue(QString("mode"),*mode);

settings.sync();
}
}

void Form_mode_change::onClouldRadioButtonClicked(bool checked)
{
if (checked) {
*mode = "QMYSQL";

emit modeChanged(*mode); // 发射模式改变信号
qDebug()<<*mode;

// 保存到QSettings
QSettings settings("MyNote","setting");

settings.setValue(QString("mode"),*mode);

settings.sync();
}
}

void Form_mode_change::on_pushButton_clicked()
{
emit push_clicked();
}

38 changes: 38 additions & 0 deletions form_mode_change.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef FORM_MODE_CHANGE_H
#define FORM_MODE_CHANGE_H

#include <QWidget>
#include<QButtonGroup>
#include<QSettings>
namespace Ui {
class Form_mode_change;
}

class Form_mode_change : public QWidget
{
Q_OBJECT

public:
explicit Form_mode_change(QWidget *parent = nullptr);
~Form_mode_change();
QButtonGroup *buttonGroup;
QString *mode;



private:
Ui::Form_mode_change *ui;

private slots:
void onLocalRadioButtonClicked(bool checked);
void onClouldRadioButtonClicked(bool checked);

void on_pushButton_clicked();

signals:
// 自定义信号,用于通知模式改变
void modeChanged(const QString &newMode);
void push_clicked();
};

#endif // FORM_MODE_CHANGE_H
97 changes: 97 additions & 0 deletions form_mode_change.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form_mode_change</class>
<widget class="QWidget" name="Form_mode_change">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>402</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>模式设置</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="local_radioButton">
<property name="text">
<string>本地模式</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/ico/local.ico</normaloff>:/ico/local.ico</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="clould_radioButton">
<property name="text">
<string>云模式</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/ico/yum.ico</normaloff>:/ico/yum.ico</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>云配置设置</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="res.qrc"/>
</resources>
<connections/>
</ui>
Loading

0 comments on commit d9d50a2

Please sign in to comment.