Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit589751f

Browse files
committed
Update ui
1 parenta1b1eb8 commit589751f

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

‎src/ui/mainwindow.cpp‎

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
4343

4444
MainWindow::~MainWindow()
4545
{
46-
instance =nullptr;
46+
delete instance;
4747
delete ui;
4848
}
4949

@@ -112,25 +112,28 @@ void MainWindow::initConnections()
112112

113113
connect(hotkey, &QHotkey::activated,this, &MainWindow::shortcutTriggered);
114114

115-
//connect(floatBtn, &QtMaterialFloatingActionButton::clicked, this, [&]() {
116-
// if (settingsWindow == nullptr) {
117-
// settingsWindow = new SettingsWindow(this);
115+
connect(floatBtn, &QtMaterialFloatingActionButton::clicked,this, [&]() {
116+
if (settingsWindow ==nullptr) {
117+
settingsWindow =newSettingsWindow(this);
118118

119-
// connect(settingsWindow, &SettingsWindow::closed, this, [&]() { settingsWindow = nullptr; });
120-
// settingsWindow->show();
121-
// settingsWindow->raise();
122-
// settingsWindow->activateWindow();
123-
// }
124-
//});
119+
connect(settingsWindow, &SettingsWindow::closed,this, [&]() { settingsWindow =nullptr; });
120+
settingsWindow->show();
121+
settingsWindow->raise();
122+
settingsWindow->activateWindow();
123+
}
124+
});
125125
}
126126

127127
voidMainWindow::loadSettings()
128128
{
129129
// QSettings settings(settingsIniFile, QSettings::IniFormat);
130130

131-
// if (settings.value("autoToggle", false).toBool()) {
132-
// autoToggle->setChecked(true);
133-
// }
131+
if (settings.value("autoToggle",false).toBool()) {
132+
ui->autoToggle->setChecked(true);
133+
}
134+
if (settings.value("hotkeyToggle",false).toBool()) {
135+
ui->hotkeyToggle->setChecked(true);
136+
}
134137

135138
registerShortcut(settings.value("shortcut","Ctrl+Shift+C").toString());
136139
}
@@ -139,9 +142,10 @@ void MainWindow::saveSettings()
139142
{
140143
// QSettings settings(settingsIniFile, QSettings::IniFormat, this);
141144

142-
//settings.setValue("autoToggle", autoToggle->isChecked());
143-
settings.setValue("shortcut",hotkey->shortcut().toString());
145+
settings.setValue("autoToggle",ui->autoToggle->isChecked());
146+
settings.setValue("hotkeyToggle",ui->hotkeyToggle->isChecked());
144147

148+
settings.setValue("shortcut", hotkey->shortcut().toString());
145149
qDebug() <<"Save shortcut:" << hotkey->shortcut().toString();
146150
}
147151

@@ -155,25 +159,25 @@ void MainWindow::autoToggleChecked(bool status)
155159
{
156160
if (status) {
157161
qDebug() <<"Auto enabled";
158-
//connect(QGuiApplication::clipboard(), &QClipboard::changed, this, &MainWindow::afterChanged);
162+
connect(QGuiApplication::clipboard(), &QClipboard::changed,this, &MainWindow::afterChanged);
159163
}else {
160164
qDebug() <<"Auto disabled";
161-
//disconnect(QGuiApplication::clipboard(), &QClipboard::changed, this, &MainWindow::afterChanged);
165+
disconnect(QGuiApplication::clipboard(), &QClipboard::changed,this, &MainWindow::afterChanged);
162166
}
163167
}
164168

165-
//void MainWindow::toggleShortcutChecked(bool status)
166-
//{
167-
// // TODO:快捷键为空、冲突时, 应该有提醒
168-
// QString seq = settings.value("shortcut", "Ctrl+Shift+C").toString();
169-
// if (status) {
170-
// qDebug() << "Shortcut enabled";
171-
// registerShortcut(seq);
172-
// } else {
173-
// qDebug() << "Shortcut disabled";
174-
// hotkey->resetShortcut();
175-
// }
176-
//}
169+
voidMainWindow::hotkeyToggleChecked(bool status)
170+
{
171+
// TODO:快捷键为空、冲突时, 应该有提醒
172+
QString seq = settings.value("shortcut","Ctrl+Shift+C").toString();
173+
if (status) {
174+
qDebug() <<"Shortcut enabled";
175+
registerShortcut(seq);
176+
}else {
177+
qDebug() <<"Shortcut disabled";
178+
hotkey->resetShortcut();
179+
}
180+
}
177181

178182
// Register shortcut
179183
voidMainWindow::registerShortcut(const QKeySequence &keySequence)

‎src/ui/mainwindow.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MainWindow : public QMainWindow
3535
voidsaveSettings();
3636

3737
voidautoToggleChecked(bool status);
38-
//voidtoggleShortcutChecked(bool status);
38+
voidhotkeyToggleChecked(bool status);
3939

4040
voidregisterShortcut(const QKeySequence &keySequence);
4141
voidshortcutTriggered();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp