Skip to content

Commit

Permalink
Github Issue #12: Added an empty dialogue to be able to show to show/…
Browse files Browse the repository at this point in the history
…switch recently opened files using Ctrl + tab. Currently opens the dialogue box but can't close it
  • Loading branch information
AngryFender committed Aug 15, 2023
1 parent 483748c commit 3ed0ea3
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ set(PROJECT_SOURCES
appeventfilter.cpp
resources/icons.qrc
startuptext.h
recentfilesdialog.h
recentfilesdialog.cpp
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
Expand Down
20 changes: 16 additions & 4 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ MainWindow::MainWindow(QWidget *parent)
QObject::connect(shiftTimer,&QTimer::timeout,
this, &MainWindow::shiftTimerHandle);

QObject::connect(this,&MainWindow::openRecentFilesDialog,
view_handler.get(),&ViewsHandler::openRecentFilesDialogHandle);

QObject::connect(this,&MainWindow::startSearchAll,
view_handler.get(),&ViewsHandler::startTextSearchInAllFilesHandle);
}
Expand Down Expand Up @@ -57,16 +60,25 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
}
shiftTimer->start(200);
}break;

case Qt::Key_Tab:
if( event->modifiers() == Qt::CTRL){
emit openRecentFilesDialog(true);
}break;
default:;
}
QMainWindow::keyPressEvent(event);
}

void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Alt){
fileSearchBox->hide();
folderTreeBox->hide();
mkEditorBox->hide();
switch(event->key()){
case Qt::Key_Alt:{
fileSearchBox->hide();
folderTreeBox->hide();
mkEditorBox->hide();
}break;
case Qt::Key_Control: emit openRecentFilesDialog(false); break;
}
QMainWindow::keyReleaseEvent(event);
}
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private slots:
void setup_views(QWidget *parent, Ui::MainWindow &ui);

signals:
void openRecentFilesDialog(bool show);
void startSearchAll();
};
#endif // MAINWINDOW_H
6 changes: 6 additions & 0 deletions recentfilesdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "recentfilesdialog.h"

RecentFilesDialog::RecentFilesDialog(QWidget * parent):QDialog(parent)
{

}
15 changes: 15 additions & 0 deletions recentfilesdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef RECENTFILESDIALOG_H
#define RECENTFILESDIALOG_H

#include <QDialog>
#include <QObject>
#include <QWidget>

class RecentFilesDialog : public QDialog
{
Q_OBJECT
public:
RecentFilesDialog(QWidget*parent = nullptr);
};

#endif // RECENTFILESDIALOG_H
8 changes: 8 additions & 0 deletions views_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ void ViewsHandler::displayTextSearchedFilePosition(QString &filePath,int searchT

}

void ViewsHandler::openRecentFilesDialogHandle(bool show)
{
if(show)
recentFilesView->show();
else
recentFilesView->hide();
}

void ViewsHandler::startTextSearchInAllFilesHandle()
{
if(textSearchAllView->isHidden()){
Expand Down
5 changes: 5 additions & 0 deletions views_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "textsearchworker.h"
#include "ui_mainwindow.h"
#include "searchalldialog.h"
#include "recentfilesdialog.h"

#define NAVIGATION_RATIO 100
#define EDITOR_RAIO 200
Expand All @@ -30,16 +31,19 @@ class ViewsHandler: public QObject
return handle;
}
~ViewsHandler(){
delete recentFilesView;
delete textSearchAllView;
}

public slots:
void openRecentFilesDialogHandle(bool show);
void startTextSearchInAllFilesHandle();

private:
ViewsHandler(QWidget*parent,Ui::MainWindow &ui){
firstDirectoryLoad = true;
this->parent = parent;
recentFilesView = new RecentFilesDialog(this->parent);
textSearchAllView = new SearchAllDialog(this->parent);
initViews(ui);
initConnection();
Expand All @@ -50,6 +54,7 @@ public slots:

QWidget *parent;
QThread searchThread;
RecentFilesDialog *recentFilesView;
SearchAllDialog *textSearchAllView;
QFrame *viewLeftFrame;
TextSearchWorker textSearchWorker;
Expand Down

0 comments on commit 3ed0ea3

Please sign in to comment.