Allow locking layout
This commit is contained in:
parent
3f7e6d08e5
commit
c6fbe9fbf1
|
@ -185,6 +185,8 @@ set(REQUIRED_ICONS
|
|||
go-next
|
||||
expand-menu-hover
|
||||
autocorrection
|
||||
unlock
|
||||
lock
|
||||
)
|
||||
|
||||
# find c++utilities
|
||||
|
|
|
@ -236,6 +236,12 @@ QString &mainWindowCurrentFileBrowserDirectory()
|
|||
return v;
|
||||
}
|
||||
|
||||
bool &mainWindowLayoutLocked()
|
||||
{
|
||||
static bool v = false;
|
||||
return v;
|
||||
}
|
||||
|
||||
// db query
|
||||
bool &dbQueryWidgetShown()
|
||||
{
|
||||
|
@ -425,9 +431,9 @@ void restore()
|
|||
break;
|
||||
}
|
||||
forceIndexPosition() = settings.value(QStringLiteral("forceindexpos"), true).toBool();
|
||||
minPadding() = settings.value(QStringLiteral("minpad"), 0).toInt();
|
||||
maxPadding() = settings.value(QStringLiteral("maxpad"), 0).toInt();
|
||||
preferredPadding() = settings.value(QStringLiteral("prefpad"), 0).toInt();
|
||||
minPadding() = settings.value(QStringLiteral("minpad"), 0).toUInt();
|
||||
maxPadding() = settings.value(QStringLiteral("maxpad"), 0).toUInt();
|
||||
preferredPadding() = settings.value(QStringLiteral("prefpad"), 0).toUInt();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
||||
|
@ -435,6 +441,7 @@ void restore()
|
|||
mainWindowGeometry() = settings.value(QStringLiteral("geometry")).toByteArray();
|
||||
mainWindowState() = settings.value(QStringLiteral("windowstate")).toByteArray();
|
||||
mainWindowCurrentFileBrowserDirectory() = settings.value(QStringLiteral("currentfilebrowserdirectory")).toString();
|
||||
mainWindowLayoutLocked() = settings.value(QStringLiteral("layoutlocked"), mainWindowLayoutLocked()).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("dbquery"));
|
||||
|
@ -520,6 +527,7 @@ void save()
|
|||
settings.setValue(QStringLiteral("geometry"), mainWindowGeometry());
|
||||
settings.setValue(QStringLiteral("windowstate"), mainWindowState());
|
||||
settings.setValue(QStringLiteral("currentfilebrowserdirectory"), mainWindowCurrentFileBrowserDirectory());
|
||||
settings.setValue(QStringLiteral("layoutlocked"), mainWindowLayoutLocked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("dbquery"));
|
||||
|
|
|
@ -102,6 +102,7 @@ KnownFieldModel &autoCorrectionFields();
|
|||
QByteArray &mainWindowGeometry();
|
||||
QByteArray &mainWindowState();
|
||||
QString &mainWindowCurrentFileBrowserDirectory();
|
||||
bool &mainWindowLayoutLocked();
|
||||
|
||||
// db query
|
||||
bool &dbQueryWidgetShown();
|
||||
|
|
|
@ -116,10 +116,14 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
m_ui->dbQueryDockWidget->setVisible(false);
|
||||
}
|
||||
|
||||
// restore locked
|
||||
setLayoutLocked(Settings::mainWindowLayoutLocked());
|
||||
|
||||
// connect signals and slots, install event filter
|
||||
// menu: application
|
||||
connect(m_ui->actionSettings, &QAction::triggered, this, &MainWindow::showSettingsDlg);
|
||||
connect(m_ui->actionOpen_MusicBrainz_search, &QAction::triggered, this, &MainWindow::showDbQueryWidget);
|
||||
connect(m_ui->lockLayout, &QAction::triggered, this, &MainWindow::toggleLayoutLocked);
|
||||
connect(m_ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
|
||||
// menu: file
|
||||
connect(m_ui->actionOpen, &QAction::triggered, this, &MainWindow::showOpenFileDlg);
|
||||
|
@ -159,7 +163,7 @@ MainWindow::~MainWindow()
|
|||
/*!
|
||||
* \brief Returns directory the file browser is currently showning.
|
||||
*/
|
||||
QString MainWindow::currentDirectory()
|
||||
QString MainWindow::currentDirectory() const
|
||||
{
|
||||
return m_ui->pathLineEdit->text();
|
||||
}
|
||||
|
@ -173,6 +177,39 @@ void MainWindow::setCurrentDirectory(const QString &path)
|
|||
m_ui->pathLineEdit->editText(path);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns whether the layout is \a locked.
|
||||
*/
|
||||
bool MainWindow::isLayoutLocked() const
|
||||
{
|
||||
return m_ui->fileSelectionDockWidget->features() == QDockWidget::NoDockWidgetFeatures;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets whether the layout is \a locked.
|
||||
*/
|
||||
void MainWindow::setLayoutLocked(bool locked)
|
||||
{
|
||||
if(locked != isLayoutLocked()) {
|
||||
if(locked) {
|
||||
m_ui->fileSelectionDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
m_ui->dbQueryDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
m_ui->lockLayout->setText(tr("Unlock layout"));
|
||||
m_ui->lockLayout->setIcon(QIcon::fromTheme(QStringLiteral("unlock")));
|
||||
} else {
|
||||
m_ui->fileSelectionDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||
m_ui->dbQueryDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
|
||||
m_ui->lockLayout->setText(tr("Lock layout"));
|
||||
m_ui->lockLayout->setIcon(QIcon::fromTheme(QStringLiteral("lock")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleLayoutLocked()
|
||||
{
|
||||
setLayoutLocked(!isLayoutLocked());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Starts parsing the specified file.
|
||||
*/
|
||||
|
@ -194,6 +231,7 @@ bool MainWindow::event(QEvent *event)
|
|||
Settings::mainWindowGeometry() = saveGeometry();
|
||||
Settings::mainWindowState() = saveState();
|
||||
Settings::mainWindowCurrentFileBrowserDirectory() = currentDirectory();
|
||||
Settings::mainWindowLayoutLocked() = isLayoutLocked();
|
||||
Settings::dbQueryWidgetShown() = m_ui->dbQueryDockWidget->isVisible();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -36,14 +36,21 @@ class DbQueryWidget;
|
|||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString currentDirectory READ currentDirectory WRITE setCurrentDirectory)
|
||||
Q_PROPERTY(bool layoutLocked READ isLayoutLocked WRITE setLayoutLocked)
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
// file browser
|
||||
QString currentDirectory();
|
||||
QString currentDirectory() const;
|
||||
bool isLayoutLocked() const;
|
||||
|
||||
public slots:
|
||||
void setCurrentDirectory(const QString &path);
|
||||
void setLayoutLocked(bool locked);
|
||||
void toggleLayoutLocked();
|
||||
void startParsing(const QString &path);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
</property>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionOpen_MusicBrainz_search"/>
|
||||
<addaction name="lockLayout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
<addaction name="separator"/>
|
||||
|
@ -343,15 +344,24 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save-as"/>
|
||||
<iconset theme="document-save-as">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save (entered tags) as ...</string>
|
||||
<string>Save (entered tags) &as ...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="lockLayout">
|
||||
<property name="icon">
|
||||
<iconset theme="lock"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Lock layout</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -44,6 +44,7 @@ class TagEditorWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString currentPath READ currentPath NOTIFY currentPathChanged)
|
||||
Q_PROPERTY(bool tagEditShown READ isTagEditShown)
|
||||
Q_PROPERTY(QByteArray fileInfoHtml READ fileInfoHtml)
|
||||
Q_PROPERTY(bool fileNameVisible READ isFileNameVisible WRITE setFileNameVisible)
|
||||
Q_PROPERTY(bool buttonsVisible READ areButtonsVisible WRITE setButtonVisible)
|
||||
|
|
Loading…
Reference in New Issue