mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-11 10:45:39 +03:00
WIP
This commit is contained in:
parent
981adc8c65
commit
31ccf5c7e3
@ -39,8 +39,10 @@ DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent)
|
|||||||
connect(context, contextSignal, [this](int value) {
|
connect(context, contextSignal, [this](int value) {
|
||||||
mConfig.setValue("diff.context", value);
|
mConfig.setValue("diff.context", value);
|
||||||
foreach (MainWindow *window, MainWindow::windows()) {
|
foreach (MainWindow *window, MainWindow::windows()) {
|
||||||
for (int i = 0; i < window->count(); ++i)
|
for (int i = 0; i < window->count(); ++i) {
|
||||||
window->view(i)->refresh();
|
if (auto v = window->view(i))
|
||||||
|
v->refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -64,8 +66,10 @@ DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (MainWindow *window, MainWindow::windows()) {
|
foreach (MainWindow *window, MainWindow::windows()) {
|
||||||
for (int i = 0; i < window->count(); ++i)
|
for (int i = 0; i < window->count(); ++i) {
|
||||||
window->view(i)->refresh();
|
if (auto v = window->view(i))
|
||||||
|
v->refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -165,8 +165,10 @@ public:
|
|||||||
connect(mFetch, &QCheckBox::toggled, this, [](bool checked) {
|
connect(mFetch, &QCheckBox::toggled, this, [](bool checked) {
|
||||||
Settings::instance()->setValue(Setting::Id::FetchAutomatically, checked);
|
Settings::instance()->setValue(Setting::Id::FetchAutomatically, checked);
|
||||||
foreach (MainWindow *window, MainWindow::windows()) {
|
foreach (MainWindow *window, MainWindow::windows()) {
|
||||||
for (int i = 0; i < window->count(); ++i)
|
for (int i = 0; i < window->count(); ++i) {
|
||||||
window->view(i)->startFetchTimer();
|
if (auto v = window->view(i))
|
||||||
|
v->startFetchTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
|
||||||
return mWindow->count() ? dict().size() : 0;
|
return mWindow->repoCount() ? dict().size() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -117,7 +117,8 @@ MainWindow::MainWindow(const git::Repository &repo, QWidget *parent,
|
|||||||
|
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
for (int i = 0; i < count(); ++i)
|
for (int i = 0; i < count(); ++i)
|
||||||
view(i)->refresh();
|
if (auto v = view(i))
|
||||||
|
v->refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ MainWindow::MainWindow(const git::Repository &repo, QWidget *parent,
|
|||||||
&MainWindow::updateTabNames);
|
&MainWindow::updateTabNames);
|
||||||
|
|
||||||
setCentralWidget(tabs);
|
setCentralWidget(tabs);
|
||||||
|
tabs->addWelcomeTab();
|
||||||
|
|
||||||
if (repo)
|
if (repo)
|
||||||
addTab(repo);
|
addTab(repo);
|
||||||
@ -167,7 +169,11 @@ RepoView *MainWindow::addTab(const QString &path) {
|
|||||||
|
|
||||||
TabWidget *tabs = tabWidget();
|
TabWidget *tabs = tabWidget();
|
||||||
for (int i = 0; i < tabs->count(); i++) {
|
for (int i = 0; i < tabs->count(); i++) {
|
||||||
RepoView *view = static_cast<RepoView *>(tabs->widget(i));
|
RepoView *view = dynamic_cast<RepoView *>(tabs->widget(i));
|
||||||
|
if (!view) {
|
||||||
|
// Tab 0 is the welcome tab
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (path == view->repo().dir(false).path()) {
|
if (path == view->repo().dir(false).path()) {
|
||||||
tabs->setCurrentIndex(i);
|
tabs->setCurrentIndex(i);
|
||||||
return view;
|
return view;
|
||||||
@ -190,7 +196,11 @@ RepoView *MainWindow::addTab(const git::Repository &repo) {
|
|||||||
|
|
||||||
TabWidget *tabs = tabWidget();
|
TabWidget *tabs = tabWidget();
|
||||||
for (int i = 0; i < tabs->count(); i++) {
|
for (int i = 0; i < tabs->count(); i++) {
|
||||||
RepoView *view = static_cast<RepoView *>(tabs->widget(i));
|
RepoView *view = dynamic_cast<RepoView *>(tabs->widget(i));
|
||||||
|
if (!view) {
|
||||||
|
// Tab 0 is the welcome tab
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (dir.path() == view->repo().dir(false).path()) {
|
if (dir.path() == view->repo().dir(false).path()) {
|
||||||
tabs->setCurrentIndex(i);
|
tabs->setCurrentIndex(i);
|
||||||
return view;
|
return view;
|
||||||
@ -223,12 +233,14 @@ RepoView *MainWindow::addTab(const git::Repository &repo) {
|
|||||||
|
|
||||||
int MainWindow::count() const { return tabWidget()->count(); }
|
int MainWindow::count() const { return tabWidget()->count(); }
|
||||||
|
|
||||||
|
int MainWindow::repoCount() const { return tabWidget()->count() - 1; }
|
||||||
|
|
||||||
RepoView *MainWindow::currentView() const {
|
RepoView *MainWindow::currentView() const {
|
||||||
return static_cast<RepoView *>(tabWidget()->currentWidget());
|
return dynamic_cast<RepoView *>(tabWidget()->currentWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
RepoView *MainWindow::view(int index) const {
|
RepoView *MainWindow::view(int index) const {
|
||||||
return static_cast<RepoView *>(tabWidget()->widget(index));
|
return dynamic_cast<RepoView *>(tabWidget()->widget(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *MainWindow::activeWindow() {
|
MainWindow *MainWindow::activeWindow() {
|
||||||
@ -428,9 +440,11 @@ void MainWindow::updateTabNames() {
|
|||||||
QList<TabName> fullNames;
|
QList<TabName> fullNames;
|
||||||
|
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
TabName name(view(i)->repo().dir(false).path());
|
if (auto v = view(i)) {
|
||||||
names[name.name()].append(i);
|
TabName name(v->repo().dir(false).path());
|
||||||
fullNames.append(name);
|
names[name.name()].append(i);
|
||||||
|
fullNames.append(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QList<int>>::key_iterator first;
|
QHash<QString, QList<int>>::key_iterator first;
|
||||||
@ -543,8 +557,10 @@ void MainWindow::updateWindowTitle(int ahead, int behind) {
|
|||||||
|
|
||||||
QStringList MainWindow::paths() const {
|
QStringList MainWindow::paths() const {
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
for (int i = 0; i < count(); ++i)
|
for (int i = 0; i < count(); ++i) {
|
||||||
paths.append(view(i)->repo().dir(false).path());
|
if (auto v = view(i))
|
||||||
|
paths.append(v->repo().dir(false).path());
|
||||||
|
}
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
RepoView *addTab(const git::Repository &repo);
|
RepoView *addTab(const git::Repository &repo);
|
||||||
|
|
||||||
int count() const;
|
int count() const;
|
||||||
|
int repoCount() const;
|
||||||
RepoView *currentView() const;
|
RepoView *currentView() const;
|
||||||
RepoView *view(int index) const;
|
RepoView *view(int index) const;
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ void openCloneDialog(CloneDialog::Kind kind) {
|
|||||||
QObject::connect(dialog, &CloneDialog::accepted, [dialog] {
|
QObject::connect(dialog, &CloneDialog::accepted, [dialog] {
|
||||||
if (MainWindow *window = MainWindow::open(dialog->path())) {
|
if (MainWindow *window = MainWindow::open(dialog->path())) {
|
||||||
RepoView *view = window->currentView();
|
RepoView *view = window->currentView();
|
||||||
view->addLogEntry(dialog->message(), dialog->messageTitle());
|
if (view)
|
||||||
|
view->addLogEntry(dialog->message(), dialog->messageTitle());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -322,8 +323,9 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (MainWindow *win = qobject_cast<MainWindow *>(window)) {
|
if (MainWindow *win = qobject_cast<MainWindow *>(window)) {
|
||||||
if (win->count() > 0) {
|
if (win->count() > 1) {
|
||||||
win->currentView()->close();
|
if (auto c = win->currentView())
|
||||||
|
c->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,7 +441,8 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
connect(mFind, &QAction::triggered, [] {
|
connect(mFind, &QAction::triggered, [] {
|
||||||
QWidget *widget = QApplication::activeWindow();
|
QWidget *widget = QApplication::activeWindow();
|
||||||
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
||||||
window->currentView()->find();
|
if (auto c = window->currentView())
|
||||||
|
c->find();
|
||||||
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
||||||
window->widget()->find();
|
window->widget()->find();
|
||||||
}
|
}
|
||||||
@ -450,7 +453,8 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
connect(mFindNext, &QAction::triggered, [] {
|
connect(mFindNext, &QAction::triggered, [] {
|
||||||
QWidget *widget = QApplication::activeWindow();
|
QWidget *widget = QApplication::activeWindow();
|
||||||
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
||||||
window->currentView()->findNext();
|
if (auto c = window->currentView())
|
||||||
|
c->findNext();
|
||||||
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
||||||
window->widget()->findNext();
|
window->widget()->findNext();
|
||||||
}
|
}
|
||||||
@ -461,7 +465,8 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
connect(mFindPrevious, &QAction::triggered, [] {
|
connect(mFindPrevious, &QAction::triggered, [] {
|
||||||
QWidget *widget = QApplication::activeWindow();
|
QWidget *widget = QApplication::activeWindow();
|
||||||
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
if (MainWindow *window = qobject_cast<MainWindow *>(widget)) {
|
||||||
window->currentView()->findPrevious();
|
if (auto c = window->currentView())
|
||||||
|
c->findPrevious();
|
||||||
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
} else if (EditorWindow *window = qobject_cast<EditorWindow *>(widget)) {
|
||||||
window->widget()->findPrevious();
|
window->widget()->findPrevious();
|
||||||
}
|
}
|
||||||
@ -753,10 +758,12 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
RepoView *view = win->currentView();
|
RepoView *view = win->currentView();
|
||||||
foreach (const git::Submodule &submodule, view->repo().submodules()) {
|
if (view) {
|
||||||
QAction *action = mOpenSubmodule->addAction(submodule.name());
|
foreach (const git::Submodule &submodule, view->repo().submodules()) {
|
||||||
connect(action, &QAction::triggered,
|
QAction *action = mOpenSubmodule->addAction(submodule.name());
|
||||||
[view, submodule] { view->openSubmodule(submodule); });
|
connect(action, &QAction::triggered,
|
||||||
|
[view, submodule] { view->openSubmodule(submodule); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -893,13 +900,14 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
QAction *diffs = debug->addAction(tr("Load All Diffs"));
|
QAction *diffs = debug->addAction(tr("Load All Diffs"));
|
||||||
connect(diffs, &QAction::triggered, [this] {
|
connect(diffs, &QAction::triggered, [this] {
|
||||||
if (MainWindow *win = qobject_cast<MainWindow *>(window())) {
|
if (MainWindow *win = qobject_cast<MainWindow *>(window())) {
|
||||||
RepoView *view = win->currentView();
|
if (RepoView *view = win->currentView()) {
|
||||||
CommitList *commits = view->commitList();
|
CommitList *commits = view->commitList();
|
||||||
QAbstractItemModel *model = commits->model();
|
QAbstractItemModel *model = commits->model();
|
||||||
for (int i = 0; i < model->rowCount(); ++i) {
|
for (int i = 0; i < model->rowCount(); ++i) {
|
||||||
commits->setCurrentIndex(model->index(i, 0));
|
commits->setCurrentIndex(model->index(i, 0));
|
||||||
view->find(); // Force editors to load.
|
view->find(); // Force editors to load.
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -907,9 +915,11 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) {
|
|||||||
QAction *walk = debug->addAction(tr("Walk Commits"));
|
QAction *walk = debug->addAction(tr("Walk Commits"));
|
||||||
connect(walk, &QAction::triggered, [this] {
|
connect(walk, &QAction::triggered, [this] {
|
||||||
if (MainWindow *win = qobject_cast<MainWindow *>(window())) {
|
if (MainWindow *win = qobject_cast<MainWindow *>(window())) {
|
||||||
git::RevWalk walker = win->currentView()->repo().walker();
|
if (auto c = win->currentView()) {
|
||||||
while (git::Commit commit = walker.next())
|
git::RevWalk walker = c->repo().walker();
|
||||||
(void)commit;
|
while (git::Commit commit = walker.next())
|
||||||
|
(void)commit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1132,8 +1142,9 @@ void MenuBar::updateHistory() {
|
|||||||
|
|
||||||
void MenuBar::updateWindow() {
|
void MenuBar::updateWindow() {
|
||||||
MainWindow *win = qobject_cast<MainWindow *>(window());
|
MainWindow *win = qobject_cast<MainWindow *>(window());
|
||||||
mPrevTab->setEnabled(win && win->count() > 1);
|
// First tab is the welcome tab
|
||||||
mNextTab->setEnabled(win && win->count() > 1);
|
mPrevTab->setEnabled(win && win->count() > 2);
|
||||||
|
mNextTab->setEnabled(win && win->count() > 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *MenuBar::window() const {
|
QWidget *MenuBar::window() const {
|
||||||
@ -1150,7 +1161,10 @@ QList<RepoView *> MenuBar::views() const {
|
|||||||
|
|
||||||
QList<RepoView *> repos;
|
QList<RepoView *> repos;
|
||||||
for (int i = 0; i < win->count(); i++) {
|
for (int i = 0; i < win->count(); i++) {
|
||||||
repos.append(win->view(i));
|
auto* view = win->view(i);
|
||||||
|
if (view) {
|
||||||
|
repos.append(view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return repos;
|
return repos;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,9 @@ public:
|
|||||||
if (!mShowFullPath)
|
if (!mShowFullPath)
|
||||||
return mTabs->tabText(row);
|
return mTabs->tabText(row);
|
||||||
|
|
||||||
RepoView *view = static_cast<RepoView *>(mTabs->widget(row));
|
RepoView *view = dynamic_cast<RepoView *>(mTabs->widget(row));
|
||||||
|
if (!view)
|
||||||
|
return QStringLiteral("");
|
||||||
return view->repo().dir(false).path();
|
return view->repo().dir(false).path();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +447,10 @@ public:
|
|||||||
if (!mTabs->count())
|
if (!mTabs->count())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
QWidget *widget = mTabs->widget(row);
|
QWidget *widget = mTabs->widget(row);
|
||||||
RepoView *view = static_cast<RepoView *>(widget);
|
RepoView *view = dynamic_cast<RepoView *>(widget);
|
||||||
|
if (!view) {
|
||||||
|
return QStringLiteral("");
|
||||||
|
}
|
||||||
return view->repo().dir(false).path();
|
return view->repo().dir(false).path();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,7 +497,10 @@ public:
|
|||||||
switch (parent.row()) {
|
switch (parent.row()) {
|
||||||
case Repo:
|
case Repo:
|
||||||
if (mTabs->count()) {
|
if (mTabs->count()) {
|
||||||
RepoView *view = static_cast<RepoView *>(mTabs->widget(row));
|
RepoView *view = dynamic_cast<RepoView *>(mTabs->widget(row));
|
||||||
|
if (!view) {
|
||||||
|
return QStringLiteral("");
|
||||||
|
}
|
||||||
return view->repo().dir(false).path();
|
return view->repo().dir(false).path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,47 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "TabBar.h"
|
#include "TabBar.h"
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr auto home_tab_width = 50;
|
||||||
|
}
|
||||||
|
|
||||||
TabBar::TabBar(QWidget *parent) : QTabBar(parent) {
|
TabBar::TabBar(QWidget *parent) : QTabBar(parent) {
|
||||||
setAutoHide(true);
|
setAutoHide(true);
|
||||||
setDocumentMode(true);
|
setDocumentMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabBar::mousePressEvent(QMouseEvent* event) {
|
||||||
|
mClickedTabIndex = tabAt(event->pos());
|
||||||
|
QTabBar::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabBar::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
qDebug() << event->pos();
|
||||||
|
// if (mClickedTabIndex == 0/*event->pos().x() <= home_tab_width || tabAt(event->pos()) == 0*/) { //
|
||||||
|
// // Ignoring first tab because this is the welcome tab
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// QTabBar::mouseMoveEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabBar::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
|
mClickedTabIndex = -1;
|
||||||
|
QTabBar::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
QSize TabBar::minimumTabSizeHint(int index) const {
|
QSize TabBar::minimumTabSizeHint(int index) const {
|
||||||
mCalculatingMinimumSize = true;
|
mCalculatingMinimumSize = true;
|
||||||
QSize size = QTabBar::minimumTabSizeHint(index);
|
QSize size = QTabBar::minimumTabSizeHint(index);
|
||||||
mCalculatingMinimumSize = false;
|
mCalculatingMinimumSize = false;
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
size.setWidth(home_tab_width);
|
||||||
|
|
||||||
// Default Tab just a small tab size on the left
|
// Default Tab just a small tab size on the left
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -28,7 +58,9 @@ QSize TabBar::tabSizeHint(int index) const {
|
|||||||
return QTabBar::tabSizeHint(index);
|
return QTabBar::tabSizeHint(index);
|
||||||
|
|
||||||
int height = fontMetrics().lineSpacing() + 12;
|
int height = fontMetrics().lineSpacing() + 12;
|
||||||
return QSize(parentWidget()->width() / count() + 1, height);
|
if (index == 0)
|
||||||
|
return QSize(home_tab_width, height);
|
||||||
|
return QSize(parentWidget()->width() / (count() - 1) + 1 - home_tab_width, height);
|
||||||
|
|
||||||
// Default Tab just a small tab size on the left
|
// Default Tab just a small tab size on the left
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,14 @@ public:
|
|||||||
TabBar(QWidget *parent = nullptr);
|
TabBar(QWidget *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
QSize minimumTabSizeHint(int index) const override;
|
QSize minimumTabSizeHint(int index) const override;
|
||||||
QSize tabSizeHint(int index) const override;
|
QSize tabSizeHint(int index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int mClickedTabIndex = -1;
|
||||||
mutable bool mCalculatingMinimumSize = false;
|
mutable bool mCalculatingMinimumSize = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,9 +43,10 @@ public:
|
|||||||
connect(clone, &QPushButton::clicked, [this] {
|
connect(clone, &QPushButton::clicked, [this] {
|
||||||
CloneDialog *dialog = new CloneDialog(CloneDialog::Clone, this);
|
CloneDialog *dialog = new CloneDialog(CloneDialog::Clone, this);
|
||||||
connect(dialog, &CloneDialog::accepted, [dialog] {
|
connect(dialog, &CloneDialog::accepted, [dialog] {
|
||||||
if (MainWindow *window = MainWindow::open(dialog->path()))
|
if (MainWindow *window = MainWindow::open(dialog->path())) {
|
||||||
window->currentView()->addLogEntry(dialog->message(),
|
if (auto c = window->currentView())
|
||||||
dialog->messageTitle());
|
c->addLogEntry(dialog->message(), dialog->messageTitle());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
dialog->open();
|
dialog->open();
|
||||||
});
|
});
|
||||||
@ -70,8 +71,8 @@ public:
|
|||||||
CloneDialog *dialog = new CloneDialog(CloneDialog::Init, this);
|
CloneDialog *dialog = new CloneDialog(CloneDialog::Init, this);
|
||||||
connect(dialog, &CloneDialog::accepted, [dialog] {
|
connect(dialog, &CloneDialog::accepted, [dialog] {
|
||||||
if (MainWindow *window = MainWindow::open(dialog->path()))
|
if (MainWindow *window = MainWindow::open(dialog->path()))
|
||||||
window->currentView()->addLogEntry(dialog->message(),
|
if (auto c = window->currentView())
|
||||||
dialog->messageTitle());
|
c->addLogEntry(dialog->message(), dialog->messageTitle());
|
||||||
});
|
});
|
||||||
dialog->open();
|
dialog->open();
|
||||||
});
|
});
|
||||||
@ -140,13 +141,10 @@ private:
|
|||||||
|
|
||||||
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) {
|
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) {
|
||||||
TabBar *bar = new TabBar(this);
|
TabBar *bar = new TabBar(this);
|
||||||
bar->setMovable(true);
|
bar->setMovable(false);
|
||||||
bar->setTabsClosable(true);
|
bar->setTabsClosable(true);
|
||||||
setTabBar(bar);
|
setTabBar(bar);
|
||||||
|
|
||||||
// Create default widget.
|
|
||||||
addTab(new DefaultWidget(this), tr("Home"));
|
|
||||||
|
|
||||||
// Handle tab close.
|
// Handle tab close.
|
||||||
connect(this, &TabWidget::tabCloseRequested, [this](int index) {
|
connect(this, &TabWidget::tabCloseRequested, [this](int index) {
|
||||||
emit tabAboutToBeRemoved();
|
emit tabAboutToBeRemoved();
|
||||||
@ -154,6 +152,13 @@ TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabWidget::addWelcomeTab() {
|
||||||
|
// Create default widget.
|
||||||
|
addTab(new DefaultWidget(this), tr("Home"));
|
||||||
|
Q_ASSERT(count() == 1);
|
||||||
|
tabBar()->setTabButton(0, QTabBar::RightSide, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void TabWidget::resizeEvent(QResizeEvent *event) {
|
void TabWidget::resizeEvent(QResizeEvent *event) {
|
||||||
QTabWidget::resizeEvent(event);
|
QTabWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ class TabWidget : public QTabWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TabWidget(QWidget *parent = nullptr);
|
TabWidget(QWidget *parent = nullptr);
|
||||||
|
void addWelcomeTab();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tabAboutToBeInserted();
|
void tabAboutToBeInserted();
|
||||||
|
Loading…
Reference in New Issue
Block a user