beginning of settings dialog

master
zetaPRIME 2022-03-18 22:59:50 -04:00
parent b4b9918c7d
commit 0f3da1f094
7 changed files with 222 additions and 10 deletions

9
notes
View File

@ -31,12 +31,9 @@ parameters {
}
TODO {
! KnobGadget rework {
- switch to relative position per frame
- shift+drag fine tuning
- alt+drag to move reference point without changing value
- global switch between horizontal and vertical
- scrollwheel support!
settings dialog {
actual window
menu action to open (single instance)
}
ping-pong for delay

View File

@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "settingsdialog.h"
using Xybrid::MainWindow;
#include <QDebug>
@ -88,13 +89,14 @@ MainWindow::MainWindow(QWidget *parent, const QString& fileName) :
updateTitle();
});
auto efa = ui->menuEdit->actions().at(0);
auto* undoAction = undoStack->createUndoAction(this, tr("&Undo"));
undoAction->setShortcuts(QKeySequence::Undo);
ui->menuEdit->addAction(undoAction);
ui->menuEdit->insertAction(efa, undoAction);
auto* redoAction = undoStack->createRedoAction(this, tr("&Redo"));
redoAction->setShortcuts(QKeySequence::Redo);
ui->menuEdit->addAction(redoAction);
ui->menuEdit->insertAction(efa, redoAction);
// prevent right pane of pattern view from being collapsed
ui->patternViewSplitter->setCollapsible(1, false);
@ -405,7 +407,7 @@ MainWindow::MainWindow(QWidget *parent, const QString& fileName) :
view->setDragMode(QGraphicsView::RubberBandDrag);
}
} else if (e->type() == QEvent::MouseButtonRelease) { // disable drag after end
QTimer::singleShot(1, [view] {
QTimer::singleShot(1, view, [view] {
view->setDragMode(QGraphicsView::NoDrag);
});
}
@ -555,6 +557,7 @@ void MainWindow::closeEvent(QCloseEvent* e) {
undoStack->clear();
setAttribute(Qt::WA_DeleteOnClose); // delete when done
openWindows.erase(this); // and remove from list now
if (openWindows.size() == 0 && SettingsDialog::instance) SettingsDialog::instance->reject();
}
bool MainWindow::eventFilter(QObject *obj [[maybe_unused]], QEvent *event) {
@ -694,6 +697,10 @@ void MainWindow::menuFileNewWindow() {
w->show();
}
void MainWindow::menuSettings() {
SettingsDialog::tryOpen();
}
void MainWindow::menuQuit() {
auto c = openWindows.size();
if (c > 1) { // prompt if more than just this window
@ -785,7 +792,7 @@ void MainWindow::updateTitle() {
if (project->fileName.isEmpty()) songTitle = qs("(new project)");
else songTitle = QFileInfo(project->fileName).baseName();
} else {
if (!project->artist.isEmpty()) songTitle = qs("%1 - %2").arg(project->artist).arg(project->title);
if (!project->artist.isEmpty()) songTitle = qs("%1 - %2").arg(project->artist, project->title);
else songTitle = project->title;
}

View File

@ -86,6 +86,7 @@ namespace Xybrid {
void menuFileExportAs();
void menuFileNewWindow();
void menuSettings();
void menuQuit();
signals:

View File

@ -1192,6 +1192,8 @@
<property name="title">
<string>Edit</string>
</property>
<addaction name="separator"/>
<addaction name="actionSettings"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
@ -1286,6 +1288,14 @@
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionSettings">
<property name="text">
<string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+F1</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@ -1460,6 +1470,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionSettings</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>menuSettings()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>459</x>
<y>305</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>menuFileNew()</slot>
@ -1470,5 +1496,6 @@
<slot>menuFileExport()</slot>
<slot>menuFileExportAs()</slot>
<slot>menuQuit()</slot>
<slot>menuSettings()</slot>
</slots>
</ui>

35
xybrid/settingsdialog.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
using namespace Xybrid;
SettingsDialog* SettingsDialog::instance = nullptr;
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog) {
ui->setupUi(this);
instance = this;
}
SettingsDialog::~SettingsDialog() {
if (instance == this) instance = nullptr;
delete ui;
}
void SettingsDialog::closeEvent(QCloseEvent *) {
if (instance == this) instance = nullptr;
}
void SettingsDialog::tryOpen() {
if (!instance) {
(new SettingsDialog(nullptr))->show();
} else {
instance->show();
instance->raise();
instance->activateWindow();
}
}

28
xybrid/settingsdialog.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include <QDialog>
namespace Ui {
class SettingsDialog;
}
namespace Xybrid {
class SettingsDialog : public QDialog {
Q_OBJECT
public:
static SettingsDialog* instance;
explicit SettingsDialog(QWidget *parent = nullptr);
~SettingsDialog() override;
void closeEvent(QCloseEvent*) override;
static void tryOpen();
private:
Ui::SettingsDialog *ui;
};
}

117
xybrid/settingsdialog.ui Normal file
View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>562</height>
</rect>
</property>
<property name="windowTitle">
<string>Xybrid Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="buttonBoxContainer" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>