Set timeline's maximum height, saner default window size on first start

parent cd763ff0
......@@ -112,7 +112,7 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QtGlobal>
#include <QScreen>
static const char version[] = KDENLIVE_VERSION;
namespace Mlt
......@@ -373,7 +373,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
if (m_recMonitor) {
tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
}
readOptions();
bool firstRun = readOptions();
QAction *action;
// Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
......@@ -473,7 +473,17 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
previewButtonAction->setDefaultWidget(timelinePreview);
addAction(QStringLiteral("timeline_preview_button"), previewButtonAction);
setupGUI();
setupGUI(QSize(1800,1000));
if (firstRun) {
QScreen *current = QApplication::primaryScreen();
if (current) {
if (current->availableSize().height() < 1000) {
resize(current->availableSize());
} else {
resize(current->availableSize() / 1.5);
}
}
}
timelinePreview->setToolButtonStyle(m_timelineToolBar->toolButtonStyle());
connect(m_timelineToolBar, &QToolBar::toolButtonStyleChanged, timelinePreview, &ProgressButton::setToolButtonStyle);
......@@ -637,7 +647,6 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
}
}
statusBar()->show();
emit GUISetupDone();
pCore->projectManager()->init(Url, clipsToLoad);
QTimer::singleShot(0, pCore->projectManager(), SLOT(slotLoadOnOpen()));
......@@ -1489,7 +1498,7 @@ void MainWindow::saveOptions()
KdenliveSettings::self()->save();
}
void MainWindow::readOptions()
bool MainWindow::readOptions()
{
KSharedConfigPtr config = KSharedConfig::openConfig();
pCore->projectManager()->recentFilesAction()->loadEntries(KConfigGroup(config, "Recent Files"));
......@@ -1513,9 +1522,11 @@ void MainWindow::readOptions()
if (KdenliveSettings::trackheight() == 0) {
KdenliveSettings::setTrackheight(50);
}
bool firstRun = false;
KConfigGroup initialGroup(config, "version");
if (!initialGroup.exists()) {
// First run, check if user is on a KDE Desktop
firstRun = true;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (env.contains(QStringLiteral("XDG_CURRENT_DESKTOP"))) {
if (env.value(QStringLiteral("XDG_CURRENT_DESKTOP")).toLower() != QLatin1String("kde")) {
......@@ -1537,6 +1548,7 @@ void MainWindow::readOptions()
}
}
initialGroup.writeEntry("version", version);
return firstRun;
}
void MainWindow::slotRunWizard()
......@@ -1733,6 +1745,7 @@ void MainWindow::connectDocument()
Timeline *trackView = pCore->projectManager()->currentTimeline();
connect(project, SIGNAL(startAutoSave()), pCore->projectManager(), SLOT(slotStartAutoSave()));
connect(project, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
connect(trackView, &Timeline::updateTimelineHeight, this, &MainWindow::updateTimelineHeight);
KdenliveSettings::setProject_fps(project->fps());
m_clipMonitorDock->raise();
m_effectStack->transitionConfig()->updateProjectFormat();
......@@ -3658,6 +3671,12 @@ void MainWindow::forceIconSet(bool force)
}
}
void MainWindow::updateTimelineHeight()
{
if (pCore->projectManager()->currentTimeline())
m_timelineToolBarContainer->setMaximumHeight(m_timelineToolBar->height() + pCore->projectManager()->currentTimeline()->maximumHeight() + 2);
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
......@@ -137,6 +137,8 @@ protected:
/** @brief Restores the window and the file when a session is loaded. */
virtual void readProperties(const KConfigGroup &config);
virtual void saveNewToolbarConfig();
/** @brief Set timeline's maximum height (depending of tracks count). */
void updateTimelineHeight();
private:
......@@ -221,7 +223,8 @@ private:
KToolBar *m_timelineToolBar;
QWidget *m_timelineToolBarContainer;
void readOptions();
/** @brief initialize startup values, return true if first run. */
bool readOptions();
void saveOptions();
virtual bool event(QEvent *e);
......
......@@ -934,6 +934,8 @@ void Timeline::adjustTrackHeaders()
for (int i = 1; i < m_tracks.count(); i++) {
m_tracks.at(i)->trackHeader->adjustSize(height);
}
setMaximumHeight(ruler_frame->height() + (m_tracks.count() - 1) * height + m_tracks.count());
emit updateTimelineHeight();
}
void Timeline::reloadTrack(int ix, int start, int end)
......
......@@ -281,6 +281,8 @@ signals:
void loadingBin(int);
/** @brief We are about to reload timeline, reset bin clip usage */
void resetUsageCount();
/** @brief Timeline height changed, inform layout */
void updateTimelineHeight();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment